Getting the URLs for the first Google search results in a shell script

后端 未结 6 1979
北恋
北恋 2021-02-06 01:19

It\'s relatively easy to parse the output of the AJAX API using a scripting language:

#!/usr/bin/env python

import urllib
import json

base = \'http://ajax.goog         


        
6条回答
  •  孤街浪徒
    2021-02-06 01:42

    Untested approach as I don't have access to a unix box currently ...

    Assuming "test" is the query string, you could use a simple wget on the following url http://www.google.co.in/#hl=en&source=hp&biw=1280&bih=705&q=test&btnI=Google+Search&aq=f&aqi=g10&aql=&oq=test&fp=3cc29334ffc8c2c

    This would leverage Google's "I'm feeling lucky" functionality and wget the first url for you. You may be able to clean up the above url a bit too.

提交回复
热议问题