如何访问令牌自动下载CSV文件

发布于 2025-02-13 05:36:09 字数 536 浏览 0 评论 0原文

我要刮擦的网站有一个按钮,要求您要下载的数据日期为.csv文件。我已经自动化了此过程以通过Python下载此数据,但是需要每次从Ctrl,Shift,i-> cookies->请求cookie下的浏览器中手动获取令牌,然后将令牌复制并粘贴到Python文件中时间。问题是1天后的令牌时间,并修改到期和/或发行日期不起作用,因此我认为该令牌是由客户端侧JavaScript生成的。

我尝试使用:

response = requests.get(www.exampleurl.com)   
print(response.cookies)

我得到一个空的响应。

我也尝试过:

print(response.headers)  

但是我根本没有获得cookie或令牌数据。

我想知道我可能会在哪里找到正在生成令牌的客户端JavaScript,以便我可以每次需要一个令牌复制算法或至少运行此JavaScript算法。

与脚本相比,我试图避免使用1GB开销,这是10MB。

The website I'm looking to scrape has a button which asks for dates of the data you want to download as a .csv file. I have automated this process to download this data via python but need to manually get a token each time from the browser under ctrl,shift,i->cookies->request cookies and then copy and paste the token into the python file each time. The problem is the token times out after 1 day and modifying the expiry and/or issue date does not work so I assume this token is being generated by client side javascript.

I have tried using:

response = requests.get(www.exampleurl.com)   
print(response.cookies)

And I get an empty response.

I've also tried:

print(response.headers)  

But I do not get the cookie or token data at all.

I want to know where I may find the client side javascript which is generating the token so I can copy the algorithm or atleast run this javascript algorithm each time I need a token.

I'm trying to avoid selenium due to it having a 1GB overhead in comparison to the script which would be 10MB.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文