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

后端 未结 6 2049
北恋
北恋 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条回答
  •  Happy的楠姐
    2021-02-06 01:52

    many years later, you can install googler

    googler -n 1 -c in -l en search something here --json

    you can control the number of output page using the n flag.

    To get only the url, simply pipe it to:

    grep "\"url\""|tr -s ' ' |cut -d ' ' -f3|tr -d "\""
    

提交回复
热议问题