reneboer / python-carnet-client

python script that emulated the VW WE Connect (formerly CarNet) web site
GNU General Public License v3.0
21 stars 9 forks source link

Use of Python library urllib #2

Closed jdrescher2006 closed 6 years ago

jdrescher2006 commented 6 years ago

I don't have the requests library available on my system. Is it possible to do the same with only urllib?

jdrescher2006 commented 6 years ago

I started with converting to urllib. First step is requesting landing page and get CSFR:

try:
    response = urllib.urlopen(base + '/portal/en_GB/web/guest/home')            
except urllib.error.HTTPError as e:
    print('HTTPError: {}'.format(e.code))
    return 0
except urllib.error.URLError as e:
    print('URLError: {}'.format(e.reason))
    return 0
print('Request OK!')    
csrf = extract_csrf(response.read())
print(csrf)

This works, i get for example: Ua5jtvrj

jdrescher2006 commented 6 years ago

Next step is request login page:

data = urllib.urlencode({'headers': AUTHHEADERS})   
data = data.encode('ascii')
response = urllib.urlopen(base + '/portal/web/guest/home/-/csrftokenhandling/get-login-url', data)
print response.read()

Unfortunately this returns a html web page and not a json file as your code does. What could be the problem?

jdrescher2006 commented 6 years ago

OK, I got the requests library running on my system. So I will close this.