伪造一个cookie来抓取一个网站在python [英] Fake a cookie to scrape a site in python

查看:1075
本文介绍了伪造一个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).

这篇关于伪造一个cookie来抓取一个网站在python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆