| The Following User Says Thank You to Kossuth For This Useful Post: | ||
| The Following 2 Users Say Thank You to Librari For This Useful Post: | ||
| The Following 3 Users Say Thank You to AapoRantalainen For This Useful Post: | ||
import urllib2
import urllib
import cookielib
# import re
from lxml import html
USERNAME = "xxxUSERxxx"
PASSWORD = "yyyPASSWDyyy"
LOGIN_URL = "https://www.geocaching.com/account/login?ReturnUrl=%2Fplay%2Fsearch"
URL = "https://www.geocaching.com/seek"
def main():
cookie = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
respon = opener.open(LOGIN_URL).read()
tree = html.fromstring(respon)
authenticity_token = list(set(tree.xpath("//input[@name='__RequestVerificationToken']/@value")))[0]
print authenticity_token
# Create payload
payload = {
"Username": USERNAME,
"Password": PASSWORD,
"__RequestVerificationToken": authenticity_token
}
# Perform login
result = opener.open(LOGIN_URL, urllib.urlencode(payload))
result.geturl()
info = result.read()
print info
if __name__ == '__main__':
main()
| The Following 5 Users Say Thank You to DNA_Splice For This Useful Post: | ||