Advertisement
stuppid_bot

Untitled

Apr 16th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import urllib
  3. import urllib2
  4. import re
  5.  
  6. # Шаг 1: парсим форму входа
  7. url = 'https://connect.mail.ru/oauth/authorize?client_id=640684&response_type=code&redirect_uri=https%3A%2F%2Fulogin.ru%2Fauth.php%3Fname%3Dmailru&scope='
  8. u = urllib.urlopen(url)
  9. # print u.info()['set-cookie']
  10. content = u.read()
  11. # content = content.decode('windows-1251')
  12. # print content
  13. matches = re.findall('<input type="hidden" name="(.*?)" value="([^"]*)', content)
  14. fields = dict(matches)
  15. # print fields
  16. name = 'OduuvGyalyulyu2000@mail.ru'
  17. pswd = 'he1gelns'
  18. name = name.split('@')
  19. fields['Domain'] = name[1]
  20. fields['Login'] = name[0]
  21. fields['Password'] = pswd
  22. # Шаг 2: пробуем авторизоваться
  23. r = urllib2.Request('https://auth.mail.ru/cgi-bin/auth',
  24.     urllib.urlencode(fields),
  25.     {'Content-Type': 'application/x-www-form-urlencoded'})
  26. u = urllib2.urlopen(r)
  27. cookie = '; '.join(re.findall(r'(?:^|(?<=, ))\w+=[^;]+', u.info()['set-cookie']))
  28. print cookie
  29. m = re.search('<meta http-equiv="refresh" content="0;url=([^"]+)', u.read())
  30. redirect_uri = m.group(1)
  31. r = urllib2.Request('https://auth.mail.ru/cgi-bin/auth',
  32.     headers={'Cookie': cookie})
  33. u = urllib2.urlopen(r)
  34. print u.info()
  35. print u.read()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement