Jump to content

Recommended Posts

(note: cURL is installed on my webhost)

 

Useful cURL class I'm using: http://paste2.org/3weaghkm

 

 

public function testNewProxies($file, $max_time = 5){
        $proxies = file_get_contents($file);
        $proxies = explode(PHP_EOL, $proxies);
        
        $fresh = array();
        
        foreach($proxies as $proxy){
            $this->curl->addSession('http://www.google.com', array(
                CURLOPT_TIMEOUT => 10,
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_PROXY => $proxy
            ));
        }
        
        $results = $this->curl->exec();
        $this->curl->clear();
        
        print_r($results);
        
        //check for fresh proxies
        for($i = 0; $i < count($proxies); $i++){
            if(strpos($results[$i], 'removed'))
                $fresh[] = $proxies[$i];
        }
        
        //write fresh proxies to new file
        $fh = fopen('proxies/proxies_checked_'.time().'.txt', 'w+');
        
        foreach($fresh as $proxy){
            fwrite($fh, $proxy.PHP_EOL);
        }
        
        fclose($fh);
        
        return count($fresh);
    }

 

The above function will run a file full of proxies and test them to see if they're good for use; however, nothing is ever returned. No errors or any data at all is returned in $results.

 

I always get this:

 

3Bwrq.png

 

or

 

3BwuB.png

 

Any ideas and/or solutions?

 

Thank you. :)

Link to comment
https://forums.phpfreaks.com/topic/280113-curlopt_proxy-failing-me/
Share on other sites

Your code doesn't show that you're even checking for errors. In your other thread I gave you some tips for looking at errors and header info returned from the curl calls.. Have you tried that? What does it output?

 

Sorry, usually soon as I post my problems I come up with a fix afterwards (should probably wait longer, but yeah).

 

I'm using the built in error function in the CURL class. Added this bit:

$errors = $this->curl->error();
print_r($errors);

3BD8m.png

 

And that was my interesting result. There's no way these are all failing; I just double checked in a proxy checking problem...and quite a bit returned working.

Edited by MySQL_Narb

It seems as if the cURL option for the PROXY just doesn't work at all. I tried this with just a regular setup.

 

 

<?php
 
$ch = curl_init('http://www.google.com');
curl_setopt($ch, CURLOPT_PROXY, '123.103.23.106:20400');
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
curl_exec($ch);
print_r(curl_getinfo($ch));
curl_close($ch);
 
?>

 

And it still returned nothing.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.