标签:cep 自己 png coding eth stat text for http
我们自己去360搜索Python发现url为:https://www.so.com/s?ie=utf-8&fr=none&src=360sou_newhome&q=Python
requests.get(url, params=kv)
params 用于追加参数到url中
import requests
def getHTMLText(url):
try:
keyword = {'ie': 'utf-8', 'fr': 'none', 'src': '360sou_newhome', 'q': 'Python'}
r = requests.get(url, params=keyword, timeout=30)
r.raise_for_status()
r.encoding = r.apparent_encoding
return r.text
except Exception as err:
return str(err)
if __name__ == '__main__':
url = 'http://www.so.com/s'
print(getHTMLText(url))
如果我们返回r.url
结果为:
标签:cep 自己 png coding eth stat text for http
原文地址:https://www.cnblogs.com/leerep/p/12445029.html