Python authorization vk.com?

There is a script that gets data from vk.com/al_friends.php. Empirically is established that it is only necessary cookies remixsid. Trying to get instructions from the Internet (use requests):

auth_params = {'act': 'login', 'email': 'soap', 'pass': 'password'}
r = requests.get('http://login.vk.com', params=auth_params)
# at this stage all is well, returns the user page as if logged in

# next you need to option __q_hash. It (the manual) pull from the page:
parse_hash = re.search('hash=([a-z0-9]+)', r.text)
hash = parse_hash.group(1)
# the only place where the hash= in the page code — link "exit" (https://login.vk.com/?act=logout&hash=...)

# now we need to make a request to vk.com/login.php using the resulting hash:
auth_params = {'act': 'slogin', 'role': 'fast', 'redirect': '1', 'to': ", 's': '1', '__q_hash': hash}
r = requests.get('http://vk.com/login.php', params=auth_params)
# and now the bummer, the page with the login form. Although the manual we need to get out of it remixsid (again, regexport from the code page)



Tried specifying the user-agent ('User-Agent': 'Mozilla/5.0' — going straight to the mobile version) and without (gives the full version).

Actually, the question is — what's wrong? Or have I misunderstood, or authorization have changed, and __q_hash now different to need.


Also welcome suggestions for alternative way of getting remixsid (copy to browser not to offer, I want full autonomy :-)
October 3rd 19 at 04:14
4 answers
October 3rd 19 at 04:16
Solution
There is of course the vk.com/dev/friends.get
Moreover, this method does not require access-token

That's what I protupil, it turns out! :-) Via API elementary, in one line, parsing is not necessary. Thank You Tsyganov_Ivan.
You only mention that the method does not require a token if the friends are open to all. Personal experience is not a small % closes friends. - geraldine91 commented on October 3rd 19 at 04:19
I could be wrong, but are you close friends? In my opinion this chip has already cut 1.5 years as - Lennie_Runolfsdott commented on October 3rd 19 at 04:22
Not wrong, wrong I just. Now we can only hide certain friends.
Half a year ago I did a program for Android and have tested getting friends with token and one without. With the token base was 20% more for this and decided to request a list with the token. - geraldine91 commented on October 3rd 19 at 04:25
October 3rd 19 at 04:18
Advertise your module to access the API vk.com: https://github.com/dimka665/vk

Implemented authorization. Works on Python2.7, Python3.3
October 3rd 19 at 04:20
I was being parsed the page and had a lot of headaches because of this =) come on until late)

I advise you to look in the direction github.com/dzhioev/vk_api_auth
Use this library in your scriptit, pulling the music) Works flawlessly.
The author simply uses urllib2.HTTPCookieProcessor(cookielib.CookieJar())
October 3rd 19 at 04:22
Parsing is more costly than using the API. The request API is not satisfied?
The social networking sites have features with authorization to access the api as a standalone app.
They definitely want that the user intervened. That is, to obtain the token necessary to open a specific url in the browser of an authorized user.
And without that action is not available to all API methods. Rather available only the most useless methods) - geraldine91 commented on October 3rd 19 at 04:25
Through the API it is possible to obtain the friends list of any user? - Lennie_Runolfsdott commented on October 3rd 19 at 04:28
There is of course the vk.com/dev/friends.get
Moreover, this method does not require access-token - geraldine91 commented on October 3rd 19 at 04:31
And who said that the script cannot be shemaleroute authorization standalone app?
Yes, I 100 times so did and do )
Available to absolutely all possible methods. - Lennie_Runolfsdott commented on October 3rd 19 at 04:34
Nobody said that) my first comments once again offers Libu that does it all and provides easy access to all API methods) - napoleon.MacGyver80 commented on October 3rd 19 at 04:37
Thank you! - Lennie_Runolfsdott commented on October 3rd 19 at 04:40

Find more questions by tags PythonVKontakte