我正在使用php XPath
进行解析。
如何在谷歌中只获取Organic Search Results
?
我试过了。。
// Grab the Google page using the chosen keywords
$html = new DOMDocument();
@$html->loadHtmlFile('https://www.google.com/search?q='.$keywords.'&num=100&gl=us');
$xpath = new DOMXPath($html);
// Store the domains to nodes
$nodes = $xpath->query('//div[@class]/cite[@class]');
但我得到的结果是空的。
我也试过//cite[@class]
,但没有得到预期的结果。
需要帮助。
以下解决方案适用于我。
$nodes = $xpath->query("//div[1]/div[@class='kv']/cite");
解析时不包括inorganic results
。