如何使用DomDocument获取与谷歌相关的搜索结果

时间:2018-02-22 21:07:38

标签: php domdocument

我想从谷歌搜索中获取所有相关的关键字。 Google Related Searches

但是当我尝试使用getElementsByTagName获取容器标记(g-section-with-header)时,它返回null。 问题是什么? 这是我的代码:

/* Createa a new DomDocument object */
$dom = new DomDocument;
/* Load the HTML */
$dom->loadHTML( file_get_contents( 'https://www.google.com/search?q=hello' ) );
$foo = $dom->getElementsByTagName( 'g-section-with-header' );
print_r( $foo );

0 个答案:

没有答案