鍍金池/ 問答/PHP  HTML/ php 用 simple_html_dom 爬蟲,怎麼爬谷歌???

php 用 simple_html_dom 爬蟲,怎麼爬谷歌???

我試著用 simple_html_dom 去爬蟲

// Create DOM from URL or file
$html = file_get_html('https://www.google.com/');

// Find all images
foreach($html->find('img') as $element)
       echo $element->src . '<br>';

// Find all links
foreach($html->find('a') as $element)
       echo $element->href . '<br>';

他提供的範例可以抓到
但我想抓搜尋結果卻出現500錯誤
我只是把url改成 https://www.google.com.tw/sea...
怎麼回事呢?!

回答
編輯回答
醉淸風

用PHTHON爬重最好

2018年1月25日 15:41