文章标题
来源:互联网 发布:手机上怎么找淘宝链接 编辑:程序博客网 时间:2024/06/07 15:35
#! /usr/bin/env python#coding=utf-8import urllib2,urllib,cookielib,requestsfrom bs4 import BeautifulSoupclass form(): def __init__(self,username,password): self.username = username self.password = password self.cj=cookielib.CookieJar() self.handler=urllib2.HTTPCookieProcessor(self.cj) self.opener=urllib2.build_opener(self.handler) urllib2.install_opener(self.opener) def get_cookie(self): self.firstCookie = "输入访问链接" req=urllib2.urlopen(self.firstCookie) cookieDick={} for index,cookie in enumerate(self.cj): cookieDick[cookie.name] = cookie.value self.csrf_test_name=cookieDick.get("csrf_cookie_name") def access(self): self.host="输入host地址" self.loginUrl=self.host+"输入访问路径" self.headers={"User-agent": "UA参数", "host": self.host} self.data={"username": self.username, "password": self.password, 'foward': 'null', 'csrf_test_name': self.csrf_test_name} dataEncode=urllib.urlencode(self.data) self.reqLogin=urllib2.Request(self.loginUrl,data=dataEncode,headers=self.headers) self.resLogin=urllib2.urlopen(self.reqLogin) self.page=self.resLogin.read() print self.pageclass login(form): def go(self): self.get_cookie() self.access()if __name__ == '__main__': test=login("username","password") test.go()
阅读全文
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 671. Second Minimum Node In a Binary Tree
- dom4j
- lunix杂记
- Java 使用 Redis
- 11Gr2 RAC udev ASM openfiler(安装文档)
- 文章标题
- varargin的用法
- 匹配两个json是否相同
- 垃圾收集之判断对象是否存活的算法
- java 50题答案
- tableView的一些坑
- Nashorn jdk8新增的ScriptEngine官方文档翻译及代码示例
- C# 对话框弹出后3秒关闭
- python里使用Future对象来异步返回结果