Checking proxy script
Finally, the last part of the post. Get ready for some “serious” programming.
- Include whatismyip.php. Don’t forget to specify URL.
- Copy getPage function to proxychecker.php or include it as a file.
- Specify a time limit.
- Write getProxies() function.
- Write deleteProxy($proxy) function.
- Specify badvars.php URL.
- Specify sleep intervals.
- Test and fix proxychecker.php. You don’t need to upload the script to a server. You can use your PC for testing.
- Deploy the script. Don’t use the same host for badvars.php and proxychecker.php.
-
<?php
-
/*
-
* TODO 1
-
* Include whatismyip.php. Don’t forget to specify URL.
-
*//*
-
* TODO 2
-
* Copy getPage (http://www.fromzerotoseo.com/scraping-websites-php-curl-proxy/)
-
* here or include it as a file.
-
/*
-
* TODO 4
-
* Load proxies from a file or database.
-
* Return array of [IP]:[port] proxies or NULL.
-
*/
-
}function deleteProxy($proxy) {
-
/*
-
* TODO 5
-
* Delete $proxy from file/database or
-
* mark as ‘bad’.
-
*/
-
}
-
-
$whatIsMyIp = new WhatIsMyIp();
-
$myIpAddress = $whatIsMyIp->getServerIpAddress();
-
echo("Can’t obtain IP address\n");
-
}
-
-
$proxies = getProxies();
-
echo("Can’t load proxies\n");
-
}
-
-
foreach ($proxies as $proxy) {
-
$result = getPage(
-
$proxy,
-
/*
-
* TODO 6
-
* Specify badvars.php URL
-
*/,
-
‘http://www.google.com/’,
-
‘Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8′,
-
1,
-
5);
-
-
deleteProxy($proxy);
-
} else {
-
/*
-
* Good proxy!
-
*/
-
}
-
} else {
-
echo($result[‘ERR’] . ‘\n’);
-
deleteProxy($proxy);
-
}
-
-
}
-
?>
Tags: PHP code, PHP script, Review script PHP, Script code, Source code
You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.


(3 votes, average: 4 out of 5)
Leave a Reply