2019年10月1日 星期二

使用cURL取得Google搜尋結果

Google最簡單的搜尋Pattern:
比如說我想搜尋nintendo switch,
https://www.google.com/search?q=nintendo+switch

但如果直接使用curl:
curl "https://www.google.com/search?q=nintendo+switch"
會出現錯誤

需要加上User Agent, 如下:
curl -A 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:69.0) Gecko/20100101 Firefox/69.0' "https://www.google.com/search?q=nintendo+switch"

就可以產生搜尋的結果了

沒有留言:

張貼留言