欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

python實現(xiàn)的登錄與提交表單數(shù)據(jù)功能示例

 更新時間:2019年09月25日 10:28:35   作者:zhaoyangjian724  
這篇文章主要介紹了python實現(xiàn)的登錄與提交表單數(shù)據(jù)功能,結(jié)合實例形式分析了Python表單登錄相關的請求與響應操作實現(xiàn)技巧,需要的朋友可以參考下

本文實例講述了python實現(xiàn)的登錄與提交表單數(shù)據(jù)功能。分享給大家供大家參考,具體如下:

# !/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib2
import urllib
import cookielib
import json
import httplib
import re
import requests
import os
import time
import requests, requests.utils, pickle
try:
  import cookielib # 兼容Python2
except:
  import http.cookiejar as cookielib
s=requests.session()
print s.headers
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
# with open('cook.txt', 'r') as f:
#  cookies = json.loads(f.read())
# print cookies
# try:
#   with open("cookies.txt", "r") as f:
#     load_cookies = json.loads(f.read())
#   s.cookies = requests.utils.cookiejar_from_dict(load_cookies)
#   print s.get('https://fms.lvchengcaifu.com/welcome').content
# except:
#
url = "https://oauth2.lvchengcaifu.com/login"
headers={
  'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0',
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
}
r= s.get(url,headers=headers,verify=False)
r=r.text
print r
print type(r)
r = r.encode('unicode-escape')
print type(r)
p = re.compile('.*_csrf"\s+value="(.*?)".*')
m = p.match(r)
token = m.group(1)
print token
headers={
  'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0',
  'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  'csrf_token': token
}
imgurl='https://oauth2.lvchengcaifu.com/Kaptcha.jpg'
r = s.get(imgurl)
r = r.content
# print s
print type(r)
print r
filename = 'E:\image.jpg'
local = open(filename, 'wb')
local.write(r)
local.close()
print "登錄二維碼已經(jīng)下載到本地" + "[" + filename + "]"
 ##打開圖片
os.system("start %s" % filename);
code = raw_input('輸入驗證碼: ')
print code
print len(code)
## <input type="hidden" id="_csrf" name="_csrf" value="6f772fd9-14da-40c4-b317-e8d9a4336203" />
login_url='https://oauth2.lvchengcaifu.com/login/form'
data = {'username': '1111', 'password': '2222@', '_csrf': token,'validCode':code}
response = s.post(login_url, data=data,headers=headers)
print response.content
aa=s.cookies
print '-------------------------------------'
print aa

更多關于Python相關內(nèi)容可查看本站專題:《Python Socket編程技巧總結(jié)》、《Python數(shù)據(jù)結(jié)構與算法教程》、《Python函數(shù)使用技巧總結(jié)》、《Python字符串操作技巧匯總》、《Python入門與進階經(jīng)典教程》及《Python文件與目錄操作技巧匯總

希望本文所述對大家Python程序設計有所幫助。

相關文章

  • python中l(wèi)ogging包的使用總結(jié)

    python中l(wèi)ogging包的使用總結(jié)

    本篇文章給大家詳細講述了python中l(wèi)ogging包的使用的相關知識點以及原理分析,有興趣的朋友可以參考學習下。
    2018-02-02
  • Flask-Vue前后端分離的全過程講解

    Flask-Vue前后端分離的全過程講解

    這篇文章主要介紹了Flask-Vue前后端分離的全過程,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-07-07
  • Python中數(shù)值比較的效率

    Python中數(shù)值比較的效率

    這篇文章主要介紹了Python中數(shù)值比較的效率,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • Python實現(xiàn)的單向循環(huán)鏈表功能示例

    Python實現(xiàn)的單向循環(huán)鏈表功能示例

    這篇文章主要介紹了Python實現(xiàn)的單向循環(huán)鏈表功能,簡單描述了單向循環(huán)鏈表的概念、原理并結(jié)合實例形式分析了Python定義與使用單向循環(huán)鏈表的相關操作技巧,需要的朋友可以參考下
    2017-11-11
  • Python列表list的詳細用法介紹

    Python列表list的詳細用法介紹

    這篇文章主要介紹了Python列表list的詳細用法介紹,列表(list)作為Python中基本的數(shù)據(jù)結(jié)構,是存儲數(shù)據(jù)的容器,相當于其它語言中所說的數(shù)組
    2022-07-07
  • python實現(xiàn)在windows下操作word的方法

    python實現(xiàn)在windows下操作word的方法

    這篇文章主要介紹了python實現(xiàn)在windows下操作word的方法,涉及Python操作word實現(xiàn)打開、插入、轉(zhuǎn)換、打印等操作的相關技巧,非常具有實用價值,需要的朋友可以參考下
    2015-04-04
  • Python從入門到精通之條件語句和循環(huán)結(jié)構詳解

    Python從入門到精通之條件語句和循環(huán)結(jié)構詳解

    Python中提供了強大而靈活的條件語句和循環(huán)結(jié)構,本文將從入門到精通地介紹它們的使用方法,并通過相關代碼進行講解,希望對大家深入了解Python有一定的幫助
    2023-07-07
  • Django中針對基于類的視圖添加csrf_exempt實例代碼

    Django中針對基于類的視圖添加csrf_exempt實例代碼

    這篇文章主要介紹了Django中針對基于類的視圖添加csrf_exempt實例代碼,分享了相關代碼示例,小編覺得還是挺不錯的,具有一定借鑒價值,需要的朋友可以參考下
    2018-02-02
  • Python中selenium庫的用法詳解

    Python中selenium庫的用法詳解

    這篇文章主要介紹了Python中selenium庫的用法詳解,需要的朋友可以參考下
    2021-05-05
  • Python 中 Elias Delta 編碼詳情

    Python 中 Elias Delta 編碼詳情

    這篇文章主要介紹了Python 中 Elias Delta 編碼,下面的文章我們將使用 python 實現(xiàn) Elias Delta 編碼。具體詳細內(nèi)容,需要的朋友可以參考一下
    2021-11-11

最新評論