你可以分析DOM的建议。在评论中,也可以利用用来刷新通过AJAX内容JSON响应的
试试这个:
$result = json_decode(file_get_contents('https://www.stratisrate.com/json/load/rate.json'), true);
// this will print the whole array under the key 'euro'
print_r($result['euro']);
//This will get you just the value you asked for
print_r($result['euro']['rate']);
JSON响应看起来是这样的:
{
"euro": {
"rate_title": "euro",
"rate": "3.37428419",
"strat": 0.296359,
"symbol": "€"
},
"dollar": {
"rate_title": "dollar",
"rate": "3.33987",
"strat": 0.299413,
"symbol": "$"
},
"bitcoin": {
"rate_title": "bitcoin",
"rate": "0.00163",
"strat": 613.496933,
"symbol": "Ƀ"
}
}
我通过查看谷歌浏览器开发工具中网络选项卡下的XHR请求发现了这一点。
然后,我只是检查打开该XHR调用的URL,并得到了结果(无身份验证令牌或登入)
阅读有关的DomDocument和解析HTML – splash58
这篇文章可能帮助你.. HTTP:// www.the-art-of-web.com/php/html-xpath-query/ –
@ splash58已经尝试过,但仍然无法弄清楚 – FluffyMe