我成功使用以下方法将特定网页读取为变量:
$content=file_get_contents('https://www.ip-tracker.org/locator/ip-lookup.php?ip=82.36.170.89');
我需要从此页面提取以下数据:
Country: United Kingdom
Capital: London
State: Camden
City Location: Hampstead
所以也许使用4个变量,例如:
$country="United Kingdom"
$capital="London"
$state="Camden"
$citylocation="Hampstead"
页面中包含所需数据的部分类似于:
<tr><th>Country:</th><td> United Kingdom <img src='images/ip-flags/gb.png' alt='IP Location Find In United Kingdom'> (GB)</td></tr><tr><th>Capital:</th><td class='tracking'>London</td></tr><tr><th>State:</th><td class='tracking lessimpt'>Camden</td></tr><tr><th>City Location:</th><td class='vazno'>Hampstead
如何吸引这些价值? 谢谢 卢卡斯