簡體   English   中英

如何使用 python 從其 url 下載鏈接的 pdf 文件?

[英]How do I download a linked pdf file from its url using python?

我有多個 URL,例如“https://static.nseindia.com/s3fs-public/2022-09/ind_prs01092022.pdf”,我想遍歷這些 URL 並將它們下載到本地文件夾。 我看到我可能需要使用 s3fs,但我不確定存儲桶名稱應該是什么。 使用 s3fs 下載文件

除非用戶代理在請求標頭中,否則 web 服務器似乎沒有響應。 這種行為相當普遍。

import requests

with requests.Session() as s:
    s.get('https://static.nseindia.com/s3fs-public/2022-09/ind_prs01092022.pdf',
           headers={'User-Agent': 'Python'}  # or any non-empty string
    )

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM