php curl 得到 2 行表
php curl get 2 row tabel
如何在 table 中获取 2 行;获取 IP 地址:端口 ?
$ch = curl_init ("http://gatherproxy.com/sockslist");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
preg_match('#<table[^>]*>(.+?)</table>#is', $page, $ip);
$result = $ip[0];
echo $result;
你应该使用像 simplehtmldom 这样的 HTML 解析器,但是如果你真的需要一个正则表达式来解析 ip 和端口,你可以使用:
$ch = curl_init ("http://gatherproxy.com/sockslist");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
preg_match_all('/document\.write\(\'(.*?)\'\).*?document\.write\(\'(.*?)\'\)/sim', $page, $matches, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($matches[0]); $i++) {
echo "PROXY: ".$matches[1][$i]. ":".$matches[2][$i]."<br>";
}
如何在 table 中获取 2 行;获取 IP 地址:端口 ?
$ch = curl_init ("http://gatherproxy.com/sockslist");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
preg_match('#<table[^>]*>(.+?)</table>#is', $page, $ip);
$result = $ip[0];
echo $result;
你应该使用像 simplehtmldom 这样的 HTML 解析器,但是如果你真的需要一个正则表达式来解析 ip 和端口,你可以使用:
$ch = curl_init ("http://gatherproxy.com/sockslist");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$page = curl_exec($ch);
preg_match_all('/document\.write\(\'(.*?)\'\).*?document\.write\(\'(.*?)\'\)/sim', $page, $matches, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($matches[0]); $i++) {
echo "PROXY: ".$matches[1][$i]. ":".$matches[2][$i]."<br>";
}