我要抓取的网站使用 js 创建 cookie。我在想的是,我可以在 python 中创建一个 cookie,然后使用该 cookie 来抓取网站。但是,我不知道这样做的任何方式。有人有什么想法吗?
请您参考如下方法:
请参阅Python httplib2 - Handling Cookies in HTTP Form Posts有关向请求添加 cookie 的示例。
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).
