【发布时间】:2017-12-19 03:07:25
【问题描述】:
我正在创建一个抓取代码,用于抓取特定郊区的每个地址。但我陷入了这个问题; “使用未定义的常量 j - 假定为 'j'”,它在 $target_url 中标识,任何人都可以帮我解决这个问题吗?
$arr = array("Illawong 2232",
"Strathfield 2135",
"Croydon 2132",
"Croydon Park 2133",
"Burwood 2134",
"Parramatta 2150",
"Hurtsville 2220",
"Seven Hills 2153",
"Blacktown 2148",
"Toongabie 2146",
"Winston Hills 2153",
"Bondi Beach 2026",
"Bondi Junction 2022",
"Coogee 2034",
"Pymble 2073",
"Miranda 2228",
"Caringbah 2229",
"Sylvania 2224",
"Drummoyne 2047",
"Concord 2137"
);
$counter = count($arr);
for($j=0;$j<$counter; $j++)
{
$arr2 = array("list-1", "list-2", "list-3","list-4", "list-5");
$count = count($arr2);
for($i=0;$count>$i;$i++)
{
//scrapping starts here
$target_url = "http://www.xxxxxxxxx.com.au/buy/".$arr[j]."/".$arr2[i]."?includeSurrounding=false";
$html = new simple_html_dom();
$html->load_file($target_url);
foreach($html->find('a[class=name]') as $vcard)
{
echo $vcard. "<br/>"
}
}
}
【问题讨论】: