Script Proxy Scraper PHP

Hello mamang kali ini kita akan membuat sebuah tools scraping dengan php

nah kali ini yang kita akan scrap adalah Proxy

kali ini kita akan nge scrap proxy dari web http://nntime.com

oke cek langsung kodingan nya



$pages = 30; // # of pages to scrape (max 30)

$proxies = array();
for ($page = 1; $page <= $pages; $page++) {


$url = "http://nntime.com/proxy-list-" . sprintf("%02d", $page) . ".htm";

$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 15
));
$data = curl_exec($ch);
curl_close($ch);

if (!empty($data)) {
$getVars = get_between($data, '");
$getVars = trim(substr($getVars, 0, -1));
$getVars = explode(";", $getVars);

$variables = array();
foreach ($getVars as $var) {
$var = explode("=", $var);
$variables[$var[0]] = $var[1];
}

preg_match_all('/onclick="choice\(\)" \/><\/td>(.*?)<\/script><\/td>/si', $data, $getProxies);
foreach ($getProxies[1] as $proxyRaw) {
$proxyIP = get_between($proxyRaw, "", "

Post a Comment

0 Comments