0

Google検索からURLのリストを取得しようとしています.urllibを使用した現在の実装は次のとおりです。

クエリは、2 つの特定のタグの最後の 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 )
4

0 に答える 0