import requests

def getHTMLText(url):
    try:
        keyword="Python"
        search={"wd":keyword}
        kv={"user-agent":"Mozilla/5.0"}
        r=requests.get(url,timeout=30,params=search,headers=kv)
        r.raise_for_status()
        r.encoding=r.apparent_encoding
        print (r.request.headers)
        return r.text
    except:
        return "产生异常"

if __name__=="__main__":
    url="http://www.baidu.com/s"
    print(getHTMLText(url))
