I
I
Ilya Fedorov2017-03-31 06:47:55
In contact with
Ilya Fedorov, 2017-03-31 06:47:55

How to parse vk.com with node.js?

Hello!
I want to get links with short names of groups (meetings) on vk.com on node.js using cheerio.

Web page screenshot
679d7f42bb634e11932cb79e4fe78caa.png

Here is the link (later I am going to substitute my city variable value into it): https://vk.com/groups?act=catalog&c%5Bcity%5D=96&c...
If we decode it, we get: https://vk.com/groups ?act=catalog&[city]=96&[count...
I have the following code:
var website_url = "https://vk.com/groups?act=catalog&c%5Bcity%5D=96&c%5Bcountry%5D=1&c%5Bsection%5D=communities&c%5Bskip_catalog%5D=1&c%5Bsort%5D=1&c%5Btype%5D=3";

request({
    uri: website_url,
    method:'POST',
    encoding:'binary'
}, function (error, response, html) {
    if (!error && response.statusCode == 200) {
        var $ = cheerio.load(html);
        $('.labeled.title').each(function(i, elem){
            var a = $(this).children();
            var url = a.attr('href');
            console.log(url);
        });
    } else if (error) {
        console.log(error);
    }
});

Using this code, I can get data from other sites, such as CNN, but from VKontakte (or facebook) there are 0 results.
Do I need an access token and where to substitute it? How are requests like this made? What kind of link to use for the request?
Thank you very much in advance!
PS VKAPI does not have the required method, but you need to get a list of meetings around the city)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Viktor, 2017-03-31
@dedmoroz007

https://vk.com/search?c%5Bcity%5D=123&c%5Bcountry%...
Try another link. There is no need for authorization or tokens.
Parsed by anything and any way

A
Alexander Aksentiev, 2017-03-31
@Sanasol

PS VKAPI does not have the required method, but you need to get a list of meetings around the city)
https://vk.com/dev/groups.search

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question