使用Python从中下载数据

2024-05-19 01:49:02 发布

您现在位置:Python中文网/ 问答频道 /正文

我一直试图使用给定代码从此URL下载文件,但出现以下错误: HTTPError:HTTP错误403:禁止。 此外,如何通过将url从*/2020/SCBSEALL0207.zip更改为*/2020/SCBSEALL0101.zip来下载多个文件

import requests
url = 'https://www.bseindia.com/BSEDATA/gross/2020/SCBSEALL0207.zip'

r = requests.get(url)
with open("Bse_20200702", "wb") as code:
    code.write(r.content)

urllib.request.urlretrieve(url, "Bse_20200702.zip")```

Tags: 文件代码httpsimporthttpurl错误code

热门问题