Cookies 模拟登录
Posted EmilySun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cookies 模拟登录相关的知识,希望对你有一定的参考价值。
#coding=utf-8 import requests from lxml import etree from multiprocessing.dummy import Pool cook={"Cookie":"your cookies"} url =\'http://weibo.cn/u/uid\' #html=requests.get(url).content #print html html=requests.get(url,cookies=cook).content #html=requests.get(url,cookies=cook).text #html=bytes(bytearray(html,encoding=\'utf-8\')) selector = etree.HTML(html) content =selector.xpath(\'//span[@class="ctt"]\') for each in content: text=each.xpath(\'string(.)\') b = 1 print text
运行结果:
方法一:
html=requests.get(url,cookies=cook).content
方法二:
html=requests.get(url,cookies=cook).text html=bytes(bytearray(html,encoding=\'utf-8\'))
极客课程--定向爬虫:简单的模拟登录 http://www.jikexueyuan.com/course/995.html
核心内容:
1.Fiddler 的介绍和使用
2.Fiddler 抓取分析数据包
3.已知 Cookies 登录新浪微博
4.Requests 模拟登录
以上是关于Cookies 模拟登录的主要内容,如果未能解决你的问题,请参考以下文章
Python Selenium.WebDriverWait 对Cookies的处理及应用『模拟登录』
Python Selenium.WebDriverWait 对Cookies的处理及应用『模拟登录』