google search with python requests library

前端 未结 3 1674
被撕碎了的回忆
被撕碎了的回忆 2020-11-29 07:47

(I\'ve tried looking but all of the other answers seem to be using urllib2)

I\'ve just started trying to use requests, but I\'m still not very clear on how to send o

3条回答
  •  悲&欢浪女
    2020-11-29 08:10

    input:

    import requests
    
    def googleSearch(query):
        with requests.session() as c:
            url = 'https://www.google.co.in'
            query = {'q': query}
            urllink = requests.get(url, params=query)
            print urllink.url
    
    googleSearch('Linkin Park')
    

    output:

    https://www.google.co.in/?q=Linkin+Park
    

提交回复
热议问题