requests 使用简单方法记录
import requests from fake_useragent import UserAgent ua = UserAgent() headers = { 'User-Agent': ua.random # 伪装 } # 这是目标url # url = 'https://www.baidu.com/s?wd=python' url = 'https://www.baidu.com/s?' # 请求参数是一个字典 即wd=python kw = {'wd': 'python'} # 带上请求参数发起请求,获取响应 response = requests.get(url, headers=headers, params=kw) print(response.text)
标签:www,wd,记录,Python,python,url,requests,headers From: https://www.cnblogs.com/jkme/p/17061540.html