Using Proxy On Script

Discussion in 'PHP' started by SNaRe, Jan 20, 2007.

  1. #1
    I wrote a script.
    I'm using file_get_contents function.
    With this function i'm getting a domain adress and taking something from this page. But i'm getting rapidly. script always uses file_get_contents
    For example google.com
    for example if you make 900 or more searchs per a day google blocks you.
    I have same problem with another site. So i want to use proxy with my script while using file_get_contents. maybe i can solve this issue. Think like your computer. It will change proxy in the script.

    How can i do it ? With which function ?
    Thank you
     
    SNaRe, Jan 20, 2007 IP
  2. ZareMedia

    ZareMedia Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    1. Get a proxy list.
    2. Use CURL
    3. Alternate the proxies with the CURL calls.
     
    ZareMedia, Jan 20, 2007 IP
  3. SNaRe

    SNaRe Well-Known Member

    Messages:
    1,132
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    165
    #3
    I tried it but it doesn't show me the content .Am i doing something wrong ?
    <?
       $cUrl = curl_init();
       curl_setopt($cUrl, CURLOPT_URL, "http://www.google.com");
       curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($cUrl, CURLOPT_TIMEOUT, 'timeout_in_seconds');
       curl_setopt($cUrl, CURLOPT_PROXY, '164.58.18.25:80');
       $pageContent = trim(curl_exec($cUrl));
       curl_close($cUrl);
       echo $pageContent;
       ?>
    Code (markup):
     
    SNaRe, Jan 20, 2007 IP
  4. ZareMedia

    ZareMedia Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    You need to set:

    set_curlopt($cUrl, CURLOPT_HTTPPROXYTUNNEL, true);
     
    ZareMedia, Jan 20, 2007 IP
  5. SNaRe

    SNaRe Well-Known Member

    Messages:
    1,132
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    165
    #5
    I pust it but no change
    and not set_curlopt - curl_setopt
    <?
       $cUrl = curl_init();
       curl_setopt($cUrl, CURLOPT_HTTPPROXYTUNNEL, true);
       curl_setopt($cUrl, CURLOPT_URL, "http://www.google.com");
       curl_setopt($cUrl, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($cUrl, CURLOPT_TIMEOUT, 'timeout_in_seconds');
       curl_setopt($cUrl, CURLOPT_PROXY, '164.58.18.25:80');
       
       $pageContent = trim(curl_exec($cUrl));
       curl_close($cUrl);
       
      
       echo $pageContent;
       ?>
    Code (markup):
     
    SNaRe, Jan 20, 2007 IP
  6. ZareMedia

    ZareMedia Peon

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    What makes you so sure that 164.58.18.25:80 is even a valid proxy? It doesn't work from here in Firefox...
     
    ZareMedia, Jan 20, 2007 IP