B
B
Bergis2019-06-15 23:50:26
Python
Bergis, 2019-06-15 23:50:26

How to make python parser online vk?

I can't make an online vk parser.
Tried to do like this:

import bs4
import requests

data = requests.get('страница')
dom = bs4.BeautifulSoup(data.text)
print(dom.select('profile_time_lv')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael, 2019-06-17
@Bergis

To get information about users, I recommend using the API
. First of all, install vk api (for simplicity, you can also generate requests manually)
pip install vk
Well, then using this construction, you get the current status:

import vk
import datetime

session1 = vk.AuthSession(access_token='твой токкен')
vk_api = vk.API(session1, v=5.62)
def get_user_status():

    value = vk_api.users.get(user_ids='4010754', fields='last_seen')
    print(value)  # <- получаешь данные вида [{'id': айди, 'first_name': 'Имя', 'last_name': 'Фамилия', 'last_seen': {'time': 1560796737, 'platform': 7}}]
    time = datetime.datetime.fromtimestamp(value[0]['last_seen']['time'])
    print(time)

get_user_status()

In the user_ids = "field, you can insert up to 1000 id separated by commas, it is also allowed to write screen_name instead of id" You
can read more in the official documentation
>>> datetime.datetime.fromtimestamp(1004260000) 
datetime.datetime(2001, 10, 28, 1, 6, 40)

Here is the transcript of the data that is returned to you:
spoiler
время последнего посещения. Объект, содержащий следующие поля:
time (integer) — время последнего посещения в формате Unixtime.
platform (integer) — тип платформы. Возможные значения:
1 — мобильная версия;
2 — приложение для iPhone;
3 — приложение для iPad;
4 — приложение для Android;
5 — приложение для Windows Phone;
6 — приложение для Windows 10;
7 — полная версия сайта.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question