Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用urllib3搜索google?_Python_Python 3.x_Google Search_Urllib3 - Fatal编程技术网

Python 如何使用urllib3搜索google?

Python 如何使用urllib3搜索google?,python,python-3.x,google-search,urllib3,Python,Python 3.x,Google Search,Urllib3,我试图从谷歌搜索中检索URL列表,以下是我当前使用urllib的实现: 查询正在最后一个fm中搜索两个特定的标记 def searchTags(tag1, tag2): query = input( 'site:last.fm/music intitle:"tags for" "'+ tag1 + '" "'+ tag2 +'"' ) query = urllib.urlencode( { 'q' : query } ) response = urllib.urlopen

我试图从谷歌搜索中检索URL列表,以下是我当前使用urllib的实现:

查询正在最后一个fm中搜索两个特定的标记

def searchTags(tag1, tag2):
    query = input( 'site:last.fm/music intitle:"tags for" "'+ tag1 + '" "'+ tag2 +'"' )
    query = urllib.urlencode( { 'q' : query } )
    response = urllib.urlopen( 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&' + query ).read()
    json = m_json.loads( response )
    results = json[ 'responseData' ][ 'results' ]
    print(results)
    for result in results:
        title = result['title']
        url = result['url']   # was URL in the original and that threw a name error exception
        print( title + '; ' + url )

您面临的具体问题是什么?首先在查询到Google后检索html,然后使用