# 模拟登录GitHub
import requests
from lxml import etree class Login():
def __init__(self):
self.headers = {
'Referer': 'https://github.com/',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36',
'Host': 'github.com'}
self.login_url = 'https://github.com/login'
self.post_url = 'https://github.com/session'
self.logined_url = 'https://github.com/settings/profile'
self.session = requests.Session() def token(self):
response = self.session.get(self.login_url, headers=self.headers)
selector = etree.HTML(response.text)
token = selector.xpath('//div//input[2]/@value')[0]
print('authenticity_token =', token)
return token def login(self, email, password):
post_data = {
'commit': 'Sign in',
'utf8': '✓',
'authenticity_token': self.token(),
'login': email,
'password': password
}
response = self.session.post(
self.post_url,
data=post_data,
headers=self.headers)
print('login status code is:', response.status_code)
print(response.cookies.get_dict())
# print(response.url)
print('response header:', response.request.headers)
if response.status_code == 200:
self.repositories_name(response.text) response = self.session.get(self.logined_url, headers=self.headers)
print('profile status code is:', response.status_code)
if response.status_code == 200:
self.logo(response.text) def repositories_name(self, html):
selector = etree.HTML(html)
repositories_name = selector.xpath(
'//li[contains(@class, "public source")]/div[@class="width-full text-bold"]/a/span[2]/text()')
print(repositories_name) def logo(self, html):
selector = etree.HTML(html)
logo_url = selector.xpath(
'//dl[contains(@class,"form-group")]/dd/img/@src')[0]
print('logo url is:', logo_url) if __name__ == "__main__":
login = Login()
login.login(email='seancheney@qq.com', password='seancheney123')

19.SimLogin_case03的更多相关文章

  1. Mediaplayer error (-19,0)

    Android MediaPlayer 发生 error (-19,0) 错误解决方法. 引起原因:由于多次实例化MediaPlayer.start() 进行播放操作引起的.由于没有及时释放内存资源导 ...

  2. 录像时调用MediaRecorder的start()时发生start failed: -19错误

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 3 ...

  3. CSharpGL(19)用glReadPixels把渲染的内容保存为PNG图片(C#)

    CSharpGL(19)用glReadPixels把渲染的内容保存为PNG图片(C#) 效果图 本文解决了将OpenGL渲染出来的内容保存到PNG图片的方法. 下载 CSharpGL已在GitHub开 ...

  4. ABP(现代ASP.NET样板开发框架)系列之19、ABP应用层——审计日志

    点这里进入ABP系列文章总目录 基于DDD的现代ASP.NET开发框架--ABP系列之19.ABP应用层——审计日志 ABP是“ASP.NET Boilerplate Project (ASP.NET ...

  5. js正则表达式校验非负浮点数:^[1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0$

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. js正则表达式校验非负整数:^\d+$ 或 ^[1-9]\d*|0$

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  7. js正则表达式校验非零的正整数:^[1-9]\d*$ 或 ^([1-9][0-9]*){1,3}$ 或 ^\+?[1-9][0-9]*$

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. C#开发微信门户及应用(19)-微信企业号的消息发送(文本、图片、文件、语音、视频、图文消息等)

    我们知道,企业号主要是面向企业需求而生的,因此内部消息的交流显得非常重要,而且发送.回复消息数量应该很可观,对于大企业尤其如此,因此可以结合企业号实现内部消息的交流.企业号具有关注安全.消息无限制等特 ...

  9. 19-typedef

    本文目录 一.typedef作用简介 二.typedef与指针 三.typedef与结构体 三.typedef与指向结构体的指针 四.typedef与枚举类型 五.typedef与指向函数的指针 六. ...

随机推荐

  1. 快速失败and安全失败

    快速失败: 举个栗子: public static void main(String[] args) { ArrayList<String> list=new ArrayList<& ...

  2. IDEA 注解开发流程

    IDEA 注解开发流程  分为以下四步  分别是 1 导入依赖 2 配置文件 applicationContext.xml 3 在需要创建对象的类上添加注解 4  测试 详细步骤和代码如下 1 导入依 ...

  3. 虚树(树形dp套路)模板——bzoj2286

    虚树的核心就是把关键点和关键点的lca重新生成一棵树,然后在这棵树上进行dp https://www.cnblogs.com/zwfymqz/p/9175152.html  写的很好的博客 建立虚树的 ...

  4. 51nod 1556 计算(递推)

    传送门 解题思路 在一个网格图上走\(n\)步,每次可以向右上,右下,右,但必须在第一象限,最后从\((0,0)\)走到\((n,0)\)的方案数为默慈金数.递推式为\(m[i+1]=\frac{(2 ...

  5. 【Python】模拟登录上海西南某高校校园网 (jaccount)

    好久没写东西了,最近学习了一下模拟登录,以校园网为例,作一记录. 去年的时候写过一篇模拟登录的文章,用的是登录后的cookies,这种操作比较傻瓜,也不智能,不够自动化,本质还是手动登录. 这次我尝试 ...

  6. 2018-2019-2-20175323 java实验二《Java面向对象程序设计》

    单元测试 1.在IDEA中新建项目并输入单元测试的代码 2.在IDEA中下载Junit,我发现Junit已经存在了 3.新建test文件 遇到的问题 发现Junit红字解析不了 解决办法:查找到jun ...

  7. 【题解】P1440 求m区间内的最小值

    求m区间内的最小值 题目描述: 一个含有n项的数列(n<=2000000),求出每一项前的m个数到它这个区间内的最小值.若前面的数不足m项则从第1个数开始,若前面没有数则输出0. 分析: 读题之 ...

  8. Codeforces 1174B Ehab Is an Odd Person

    题目链接:http://codeforces.com/problemset/problem/1174/B 题意:给定长度 n 的数组,任意俩个相加为奇数的数可以交换数组中的位置,让这个数组尽量从小到大 ...

  9. 运行mybatis项目,运行测试类,点击test后,出现Cannot start compilation: the output path is not specified for module "前......

    Cannot start compilation: the output path is not specified for module "前 后来发现是在pom.xml右击,有个+号,把 ...

  10. webAPI(DOM) 2.1 获取页面元素 | 事件1 | 属性操作 | 节点 | 创建元素 | 事件2

    js分三个部分: ECMAScript标准:js的基本语法 DOM:Ducument Object Model--->文档对象模型--->操作页面的元素 BOM:Browser Objec ...