伪造一个cookie来抓取一个网站在python

伪造一个cookie来抓取一个网站在python

问题描述:

我要尝试的网站使用js来创建Cookie。我想的是,我可以在python中创建一个cookie,然后使用该cookie来抓取网站。但是,我不知道有什么办法。是否有任何想法?

The site that I'm trying to scrape uses js to create a cookie. What I was thinking was that I can create a cookie in python and then use that cookie to scrape the site. However, I don't know any way of doing that. Does anybody have any ideas?

请参阅 Python httplib2 - 在HTTP表单帖子中处理Cookie以获取向请求添加Cookie的示例。

Please see Python httplib2 - Handling Cookies in HTTP Form Posts for an example of adding a cookie to a request.


我经常需要在基于web
的应用程序中自动执行任务。我喜欢做这个
在协议级别通过模拟
真正的用户通过HTTP的交互。
Python有两个内置的模块
:urllib(高级Web
接口)和httplib(低级
HTTP接口)。

I often need to automate tasks in web based applications. I like to do this at the protocol level by simulating a real user's interactions via HTTP. Python comes with two built-in modules for this: urllib (higher level Web interface) and httplib (lower level HTTP interface).