merkator

vkParse

Aug 5th, 2011
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. #-*-coding: cp1251 -*-
  2. import urllib2
  3. import cookielib
  4. import urllib
  5. import lxml.html
  6.  
  7. nick = 'nick'
  8. passw = 'pass'
  9.  
  10. cookie = cookielib.CookieJar()  
  11. opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie))
  12. urllib2.install_opener(opener)
  13. headers = {"User-Agent" : "Mozilla/4.0 (compatible; MSIE 5.5; WindowsNT)" }
  14. data_s = {"email":nick, "pass":passw}
  15. send_data = urllib.urlencode(data_s)
  16. u_request = urllib2.Request("http://vkontakte.ru/login.php", send_data, headers)
  17. try:
  18.     vk = urllib2.urlopen(u_request)
  19. except:
  20.     cookie = status = "ERROR"
  21.     print cookie, status
  22. else:
  23.     if "remixsid=deleted" in str(vk):
  24.         print "NO"
  25.     else:
  26.         print "YES"
  27.  
  28. vk1 = urllib2.urlopen('http://vkontakte.ru/friends?all=1')
  29. #vk2 = urllib2.urlopen('javascript: Friends.showMore()')
  30. doc = lxml.html.document_fromstring(vk1.read())
  31.  
  32. for name in doc.cssselect('div.labeled a'):
  33.     print name.text
Advertisement
Add Comment
Please, Sign In to add comment