Skip to content Skip to sidebar Skip to footer

How To Make Http Post On Website That Uses Asp.net?

I'm using Python library requests for this, but I can't seem to be able to log in to this website. The url is https://www.bet365affiliates.com/ui/pages/affiliates/, and I've been t

Solution 1:

The solution could be this: Please Take attention, you could do it without selenium. If you want to do without it, firstly you should get the main affiliate page, and from the response data you could fetch all the required information (which I gather by xpaths). I just didn't have enough time to write it in fully requests.

To gather the informations from response data you could use XML tree library. With the same XPATH method, you could easily find all the requested informations.

import requests
from selenium import webdriver

Password = 'YOURPASS'
Username = 'YOURUSERNAME'

browser = webdriver.Chrome(os.getcwd()+"/"+"Chromedriver.exe")
browser.get('https://www.bet365affiliates.com/ui/pages/affiliates/Affiliates.aspx')
VIEWSTATE=browser.find_element_by_xpath('//*[@id="__VIEWSTATE"]')
SESSIONID=browser.find_element_by_xpath('//*[@id="CMSessionId"]')
PREVPAG=browser.find_element_by_xpath('//*[@id="__PREVIOUSPAGE"]')
EVENTVALIDATION=browser.find_element_by_xpath('//* [@id="__EVENTVALIDATION"]')
cookies = browser.get_cookies()

session = requests.session()
for cookie incookies:
    print cookie['name']
    print cookie['value']
    session.cookies.set(cookie['name'], cookie['value'])   

payload = {'ctl00_AjaxScriptManager_HiddenField':'',
           '__EVENTTARGET':'ctl00$MasterHeaderPlaceHolder$ctl00$goButton',
           '__EVENTARGUMENT':'',
           '__VIEWSTATE':VIEWSTATE,
           '__PREVIOUSPAGE':PREVPAG,
           '__EVENTVALIDATION':EVENTVALIDATION,
           'txtPassword':Username,
           'txtUserName':Password,
           'CMSessionId':SESSIONID,
           'returnURL':'/ui/pages/affiliates/Affiliates.aspx',
           'ctl00$MasterHeaderPlaceHolder$ctl00$userNameTextbox':Username,
           'ctl00$MasterHeaderPlaceHolder$ctl00$passwordTextbox':Password,
           'ctl00$MasterHeaderPlaceHolder$ctl00$tempPasswordTextbox':'Password'}


session.post('https://www.bet365affiliates.com/Members/CMSitePages/SiteLogin.aspx?lng=1',data=payload)

Solution 2:

Did you inspected the http request used by the browser to log you in? You should replicate it.

FB

Post a Comment for "How To Make Http Post On Website That Uses Asp.net?"