【发布时间】:2021-12-29 19:12:04
【问题描述】:
在 Chrome 中,我将登录到一个网站。
然后我将检查该站点,转到网络并清除现有的。
然后,我将单击一个链接并抓住存储 cookie 的标题。
在 Python 中,我将标题存储在字典中,并将其用于其余代码。
def site_session(url, header_dict):
session = requests.Session()
t = session.get(url, headers=header_dict)
return soup(t.text, 'html.parser')
site = site_session('https://website.com', headers)
# Scrape the Site as usual until I reach a file I can't download..
这是一个视频文件,但没有扩展名。
"https://website.sub.com/download"
单击此链接将打开保存对话框,我可以保存它。但不是在Python中..
检查网络,它似乎重定向到我能够抓取的另一个网址。
"https://website.sub.com/download/file.mp4?jibberish-jibberish-jibberish
尝试将其缩短为“https://website.sub.com/download/file.mp4”无法打开。
with open(shortened_url, 'wb') as file:
response = requests.get(shorened_url)
file.write(response.content)
我已经尝试了完整的网址和缩短的网址并收到:
OSError: [Errno 22] 无效参数。
对此的任何帮助都会很棒!
谢谢!
【问题讨论】: