i want to print dashboard html source after successful login in paypal, Here is my full code
import requests
import lxml.html
# Get Auth & Login URL
get_login = requests.get('https://paypal.com/cgi-bin/webscr?cmd=_login-run')
get_login_response = get_login.text.encode('utf-8') #printing html source
get_login_html = lxml.html.fromstring(get_login_response) #printing <Element html at 0x7f19cb242ec0>
auth = get_login_html.xpath("//input[@name='auth']/@value") #printing [<InputElement 7fb0971e9f18 name='auth' type='hidden'>]
login_url = get_login_html.xpath("//form[@name='login_form']/@action")
# Post Login
payload = {
'login_cmd':'',
'login_params':'',
'login_email':'[email protected]',
'login_password':'jancok666',
'auth':auth[0],
'submit.x':'Log In',
'form_charset':'UTF-8',
'browser_name':'Firefox',
'browser_version':'18',
'browser_version_full':'18.0'
}
post_login = requests.post(login_url[0], data=payload)
post_login_response = post_login.text.encode('utf-8')
print post_login_response
but what i get is html source of captcha challenge like this
......... <h1 class="headerText">Security Challenge</h1><p>Type the characters you see in the image for security purposes.</p>
So how i can print dashboard html source after successful login ? whats wrong with my code ? Thank you very much :D
you need to use proxy so that the request wont be from one ip address to avoid reCAPTCHA
import requests
import lxml.html
# Get Auth & Login URL
get_login = requests.get('https://paypal.com/cgi-bin/webscr?cmd=_login-run')
get_login_response = get_login.text.encode('utf-8') #printing html source
get_login_html = lxml.html.fromstring(get_login_response) #printing <Element html at 0x7f19cb242ec0>
auth = get_login_html.xpath("//input[@name='auth']/@value") #printing [<InputElement 7fb0971e9f18 name='auth' type='hidden'>]
login_url = get_login_html.xpath("//form[@name='login_form']/@action")
# Post Login
payload = {
'login_cmd':'',
'login_params':'',
'login_email':'[email protected]',
'login_password':'jancok666',
'auth':auth[0],
'submit.x':'Log In',
'form_charset':'UTF-8',
'browser_name':'Firefox',
'browser_version':'18',
'browser_version_full':'18.0'
}
#proxy
proxy = {
'https': '1.2.3.4:1234',
'http': '1.2.3.4:1234'
}
post_login = requests.post(login_url[0], data=payload, proxies=proxy)
post_login_response = post_login.text.encode('utf-8')
print post_login_response
LIKE SO, YOU SHOULDNT GET CAPTCHA AGAIN.... :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With