登录时,我一直在查看站点的请求,但是我尝试复制它们,但是没有运气。有人可以帮我写一些代码,使我可以使用请求登录该网站。登录URL为https://www.supplystore.com.au/shop/login.aspx,该网站肯定有Recaptcha v3。
s = requests.session()
def load_task():
login_url = 'https://www.supplystore.com.au/shop/login.aspx'
r_login = s.get(login_url)
soup = bs(r_login.text, 'html.parser')
__VIEWSTATE = soup.find('input', {'name': '__VIEWSTATE'})['value']
#print(__VIEWSTATE)
__VIEWSTATEGENERATOR = soup.find('input', {'name': '__VIEWSTATEGENERATOR'})['value']
#print(__VIEWSTATEGENERATOR)
form_data = {'__EVENTTARGET': '',
'__EVENTARGUMENT': '',
'__VIEWSTATE': __VIEWSTATE,
'ctl00$ctl00$ctl00$ContentPlaceHolderDefault$PageContentPlaceholder$loginForm$UserName': user,
'ctl00$ctl00$ctl00$ContentPlaceHolderDefault$PageContentPlaceholder$loginForm$Password': password,
'ctl00$ctl00$ctl00$ContentPlaceHolderDefault$PageContentPlaceholder$loginForm$RememberMeSet': 'on',
'ctl00$ctl00$ctl00$ContentPlaceHolderDefault$PageContentPlaceholder$loginForm$RedirectUrl': '/',
'ctl00$ctl00$ctl00$ContentPlaceHolderDefault$PageContentPlaceholder$loginForm$Login': 'Login',
'__VIEWSTATEGENERATOR': __VIEWSTATEGENERATOR}
headers = {
'origin': login_url,
'referer': 'https://www.supplystore.com.au/shop/login.aspx',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36',
'DNT': '1',
}
send_r = s.post(login_url, data=form_data, headers=headers)