使用requests进行模拟登陆
import re
import requests header = {
'User-Agent': "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1",
'Referer': 'https://passport.lagou.com/login/login.html',
} session = requests.session()
r1 = session.get('https://passport.lagou.com/login/login.html',
headers=header
)
X_Anti_Forge_Token = re.findall(r"X_Anti_Forge_Token = '(.*?)'", r1.text)[0]
X_Anti_Forge_Code = re.findall(r"X_Anti_Forge_Code = '(.*?)'", r1.text)[0] # X-Anit-Forge-Code:45530844
# X-Anit-Forge-Token:7f50218e-0796-46bc-9190-1fbe6790cf56
# X-Requested-With:XMLHttpRequest header2 = header['X-Anit-Forge-Code'] = X_Anti_Forge_Code
header['X-Anit-Forge-Token'] = X_Anti_Forge_Token # print(header2) session.post('https://passport.lagou.com/login/login.json',
headers=header,
data={
'isValidate': True,
'username': '',
'password': '70621c64832c4d4d66a47be6150b4a8e',
'request_form_verifyCode': '',
'submit': '',
},
) r3=session.get('https://passport.lagou.com/grantServiceTicket/grant.html',
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
'Referer': 'https://passport.lagou.com/login/login.html',
}
) #第四步:验证
r4=session.get('https://www.lagou.com/resume/myresume.html',
headers={
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36',
}
) print('' in r4.text) r6 = session.post('https://www.lagou.com/jobs/companyAjax.json',
headers = header,
params = { },
data={ }
) print(r6.text)
使用requests进行模拟登陆的更多相关文章
- 【python爬虫】用requests库模拟登陆人人网
说明:以前是selenium登陆取cookie的方法比较复杂,改用这个 """ 用requests库模拟登陆人人网 """ import r ...
- 20170717_python爬虫之requests+cookie模拟登陆
在成功登陆之前,失败了十几次.完全找不到是什么原因导致被网站判断cookie是无效的. 直到用了firefox的httpfox之后才发现cookie里还有一个ASP.NET_SessionId 这个字 ...
- python使用requests模块模拟登陆知乎
from bs4 import BeautifulSoup import requests import time def captcha(captcha_data): with open(" ...
- 爬虫之 cookie , 验证码,模拟登陆,线程
需求文档的定制 糗事百科的段子内容和作者(xpath的管道符)名称进行爬取,然后存储到mysql中or文本 http://sc.chinaz.com/jianli/free.html爬取简历模板 HT ...
- python requests 模拟登陆网站,抓取数据
抓取页面数据的时候,有时候我们需要登陆才可以获取页面资源,那么我们需要登陆以后才可以跳转到对应的资源页面,那么我们需要通过模拟登陆,登陆成功以后再次去抓取对应的数据. 首先我们需要通过手动方式来登陆一 ...
- Requests模拟登陆
requests模拟登陆知乎网站 实例 # -*- coding: utf-8 -*- __author__ = 'CQ' import requests try: import cookielib ...
- python+requests模拟登陆 学校选课系统
最近学校让我们选课,每天都有不同的课需要选....然后突发奇想试试用python爬学校选课系统的课程信息 先把自己的浏览器缓存清空,然后在登陆界面按f12 如图: 可以看到登陆时候是需要验证码的,验证 ...
- python模拟登陆之下载
好长时间没有更新博客了,哈哈. 今天公司给了这么一个需求,现在我们需要去淘宝获取上一天的订单号,然后再根据订单号去另一个接口去获取订单详情,然后再给我展示到web! 中间涉及到的技术点有: 模拟登陆 ...
- python爬虫 模拟登陆校园网-初级
最近跟同学学习爬虫的时候看到网上有个帖子,好像是山大校园网不稳定,用py做了个模拟登陆很有趣,于是我走上了一条不归路..... 先上一张校园网截图 首先弄清一下模拟登陆的原理: 1:服务器判定浏览器登 ...
随机推荐
- python SSL处理
浏览器SSL提示 我们看一下IE的解决方案,对ie浏览器而言,需要添加Desired Capabilities的acceptSslCerts选项为True,代码如下: 的 112 / 166 #_*_ ...
- sqoop无法导出parquet文件到mysql
1.问题描述 在CDH集群中我们需要将Hive表的数据导入到RDBMS数据库中,使用Sqoop工具可以方便的将Hive表数据抽取到RDBMS数据库中,在使用Sqoop抽取Hive Parquet表时作 ...
- 最短路径问题---Dijkstra算法详解
侵删https://blog.csdn.net/qq_35644234/article/details/60870719 前言 Nobody can go back and start a new b ...
- ***在Linux环境下mysql的root密码忘记解决方法(三种)-推荐第三种
MySQL密码的恢复方法之一 1.首先确认服务器出于安全的状态,也就是没有人能够任意地连接MySQL数据库. 因为在重新设置MySQL的root密码的期间,MySQL数据库完全出于没有密码保护的 状态 ...
- python--使用递归优雅实现列表相加和进制转换
咦,好像坚持了一段时间,感觉又有新收获啦. # coding: utf-8 class Stack: def __init__(self): self.items = [] # 是否为空 def is ...
- 构造函数与 new 命令
虽然不同于传统的面向对象编程语言,但是JavaScript具有很强的面向对象编程能力.本章介绍JavaScript如何进行“面向对象编程”. 对象的概念 “面向对象编程”(Object Oriente ...
- vscode插件篇
Document This 注释插件 能够自动识别function中的参数 Ctrl + alt + D
- 【Android】Android 4.0 Launcher2源码分析——启动过程分析
Android的应用程序的入口定义在AndroidManifest.xml文件中可以找出:[html] <manifest xmlns:android="http://schemas. ...
- 未在本地计算机上注册“OraOLEDB.Oracle.1”提供程序。
问题描述:运行访问oracle数据库的.net程序时,弹出错误"未在本地计算机上注册“OraOLEDB.Oracle.1”提供程序". 系统环境:windows server 2 ...
- SQLALCHEMY_TRACK_MODIFICATIONS adds significant异常的解决方法