在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/Python/ python requests庫 模擬登陸表單數(shù)據(jù)有重復(fù),該如何提交data

python requests庫 模擬登陸表單數(shù)據(jù)有重復(fù),該如何提交data

用python requests 庫 模擬登陸,表單數(shù)據(jù)有重復(fù),該如何提交data???

import requests
from bs4 import BeautifulSoup

url = 'http://xxxxxxxxxxx/login_slogin.html'
username = input('請輸入學(xué)號:')
password = input('請輸入密碼:')
headers = {
            'user-agent': 'Mozilla / 5.0(Windows NT 10.0; Win64; x64; rv: 61.0) Gecko / 20100101 Firefox / 61.0',
            'Upgrade-Insecure-Requests':'1'
        }

httpSession = requests.Session()
r = httpSession.get(url, headers = headers)
html = httpSession.get(url, headers=headers).text
soup = BeautifulSoup(html, 'html.parser')
data = {
    'csrftoken':soup.select('#csrftoken')[0].get('value'),
    'yhm':username,
    'mm':password,
        }

httpSession.post(url, data=data, headers=headers)
resp = httpSession.get(url, headers=headers)
print(resp.text)

這是表單圖片:圖片描述

圖片描述

下面是在谷歌瀏覽器上的表單表示:
圖片描述

請問這樣的表單數(shù)據(jù)如何提交呀?

回答
編輯回答
假灑脫
data = [
    ['csrftoken', soup.select('#csrftoken')[0].get('value')],
    ['yhm', username],
    ['mm', password],
    ['mm', password]
]

httpSession.post(url, data=data, headers=headers)
2017年10月17日 08:05