web scraping - how to use python requests to login to website -
im trying login , scrape job site , send me notification when ever key words found.i think have correctly traced xpath value of feild "login[iovation]" cannot extract value, here have done far login
import requests lxml import html header = {"user-agent":"mozilla/4.0 (compatible; msie 5.5;windows nt)"} login_url = 'https://www.upwork.com/ab/account-security/login' session_requests = requests.session() #get csrf result = session_requests.get(login_url) tree=html.fromstring(result.text) auth_token = list(set(tree.xpath('//*[@name="login[_token]"]/@value'))) auth_iovat = list(set(tree.xpath('//*[@name="login[iovation]"]/@value'))) # create payload payload = { "login[username]": "myemail@gmail.com", "login[password]": "pa$$w0rd", "login[_token]": auth_token, "login[iovation]": auth_iovation, "login[redir]": "/home" } #perform login scrapeurl='https://www.upwork.com/ab/find-work/' result=session_requests.post(login_url, data = payload, headers = dict(referer = login_url)) #test result print result.text
this because upworks uses called iovation (https://www.iovation.com/) reduce fraud. iovation uses digital fingerprint of device/browser, sent via login[iovation] parameter.
if @ javascripts loaded on site, find 2 javascript being loaded iesnare.com domain. domain , many others owned iovaiton drop third party javascript identify device/browser.
i think if copy string successful login , send on along http headers including browser agent in python code, should okie.
Comments
Post a Comment