用requests自动访问网页,下载网页内容
import requests
# 请求下载excel
def downloading(text_path):
# 访问要下载的链接文件
with open(text_path) as f:
for line in f.readlines():
try:
# 获取内容,生成xls
r = requests.get(line)
excel_name = text_path[:-5] + ".xls"
with open(excel_name, "wb") as code:
code.write(r.content)
except:
print("地址错误无法下载")