# 1、引入模块
import requests
# 2、采集数据
resp = requests.get("https://www.baidu.com/more")
# 3、存储数据:io
with open("data/baidu_product.html", mode="wb") as file:
# 写入文件数据,直接存储二进制数据
file.write(resp.content)
# 拓展:采集图片数据
resp2 = requests.get("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1601201689082&di=938169173c5be52510a765642193dc41&imgtype=0&src=http%3A%2F%2Ft8.baidu.com%2Fit%2Fu%3D3571592872%2C3353494284%26fm%3D79%26app%3D86%26f%3DJPEG%3Fw%3D1200%26h%3D1290")
with open("data/my.jpg", mode="wb") as file2:
file2.write(resp2.content)