mobyklick.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/python
  2. # another way: simply
  3. # curl -vLA 'Mozilla/5.0' -X POST 'https://landing.mobyklick.de/login' -F 'login=oneclick'
  4. import re
  5. import urllib.request
  6. import urllib3
  7. headers = {}
  8. headers['User-Agent'] = 'Mozilla/5.0'
  9. pool = urllib3.PoolManager()
  10. dummy='google.com'
  11. f1 = pool.request(method='GET', url=dummy, headers=headers)
  12. h1 = f1.data
  13. forms = re.findall(b'<form.*action=["]?([^"]+)["]?[^>]*>(.*)</form>', h1, re.MULTILINE | re.DOTALL)
  14. loginaction = forms[0][0]
  15. print(forms[0][1])
  16. inputs = re.findall(b"<input[^>]*/>", forms[0][1], re.MULTILINE | re.DOTALL)
  17. print(inputs)
  18. instuff = [re.findall(b'([^ "]+)\s*=\s*["]?([^"]+)["]?', inp) for inp in inputs]
  19. print(instuff)
  20. fields = {dict(ix)[b"name"].decode(): dict(ix)[b"value"].decode() for ix in instuff}
  21. # Connected to landing.mobyklick.de (84.46.65.13) port 443 (#2)
  22. # somehow .get_redirect_location() = False
  23. href = 'https://landing.mobyklick.de%s' % loginaction.decode()
  24. # print(href)
  25. # print(fields)
  26. f3 = pool.request_encode_body(method='POST', url=href, headers=headers, fields=fields, encode_multipart=True)
  27. # print(f3.status)
  28. # print(f3.getheaders())
  29. # print(f3.data)