python爬虫
来源:互联网 发布:java 单例 并发多线程 编辑:程序博客网 时间:2024/05/29 09:14
#encoding=utf-8
import requestsfrom bs4 import BeautifulSoup#CSDN登录界面lg_url='https://passport.csdn.net/account/login?from=http%3A%2F%2Fmy.csdn.net%2Fmy%2Fmycsdn'#CSDN登录之后的页面af_url='http://my.csdn.net/my/mycsdn'header={ 'Accept':'text/html, application/xhtml+xml, image/jxr, */*', 'Accept-Language':'zh-CN', 'Connection':'Keep-Alive', 'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko'}s=requests.session()login=s.post(lg_url,headers=header)#print login.contentsoup=BeautifulSoup(login.content,'lxml')lt=soup.find('input',{'name':'lt'})['value']execution=soup.find('input',{'name':'execution'})['value']_eventId=soup.find('input',{'name':'_eventId'})['value']print lt,execution,_eventIdpwd=raw_input("Please input the password:")#需要提交的表单,表单内容可以通过审查可以看到postdata={ 'username':abc@qq.com, 'password':pwd, 'lt':lt, #CSDN 登录界面有3个(lt,execution,_eventId)隐藏的文本框,这些也必须一起提交才能登录 'execution':'e1s1', '_eventId':'submit'}s.post(lg_url,data=postdata,headers=header)#请求页面page=s.get(af_url,headers = header)#获取登录后页面print page.content
0 0
- python爬虫-->爬虫基础
- [爬虫] Python爬虫技巧
- Python爬虫
- python 爬虫
- python 爬虫
- python 爬虫
- python爬虫
- Python爬虫
- Python爬虫
- python 爬虫
- Python爬虫
- python爬虫
- python 爬虫
- python 爬虫
- python爬虫
- python爬虫
- python爬虫
- python 爬虫
- 网页中插入视频播放代码全集
- 总结 Eclipse 编程常用的快捷键
- 升了Xcode8.3 xcrun 打包不好用了
- 高德地图设置地图缩放比例
- 在Oracle中添加数据库
- python爬虫
- java 字父类 构造方法 代码块 加载顺序
- js分享代码
- linux_tar.gz 和tar.bz2 详细解释
- 6. web.xml中DispatcherServlet排除静态资源的拦截
- BGSLibrary: A Background Subtraction Library
- JSP数据和JavaScirpt数据交互使用问题
- activity和view进场和退场动画
- vim命令