Python Flask定时调度疫情大数据爬取全栈项目实战使用-5.request发送请求

python-flask xuhss 515℃ 0评论

使用request发送请求

安装:

pip install requests

request.get()

import requests

url = "http://www.baidu.com"

res.encoding = 'utf-8'
print(res.encoding)
print(res.headers)
print(res.url)

res = requests.get(url)
print(res.text)

同样也可以以加上user-agent:

import requests
header = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.190 Safari/537.36"
}
url = "http://www.baidu.com"
res = requests.get(url, headers = header)

print(res.encoding)
print(res.headers) 。
print(res.url)
print(res.status_code)
res.encoding = 'utf-8'

print(res.text)

转载请注明:xuhss » Python Flask定时调度疫情大数据爬取全栈项目实战使用-5.request发送请求

喜欢 (0)

您必须 登录 才能发表评论!