Skip to main content

Getting data from vk.com in a pythonic way.

Project description

VK Getter

Very simple and pythonic way to extract data from VK.

Getting started

Install package via pip

pip install vk_getter

Use your access token, and get posts from any public group. You can get token here.

from vk_getter import VKGetter

getter = VKGetter("TOKEN")

# get 200 latest posts from https://www.vk.com/vk
posts = getter.get_posts("vk", 200) 

# get 150 posts with offset of 50
posts = getter.get_posts("lol", 150, 50)

You can specify different settings:

posts = getter.get_latest_posts("https://www.vk.com/vk",
                                count=120,
				offset=20,
                                pinned=False,
                                allow_no_attachments=False,
                                ads=False,
                                copyright=False)

All posts are retrieved as a Python dataclasses, but can also be returned as dicts.

posts = getter.get_latest_posts(group_domain="vk",
                                count=1,
                                as_dict=True)
# posts[0] = 
#     {
#         "id": 1320761,
#         "date": "15.09.2022",
#         "time": "14:15:11",
#         "text": "...",
#         "attachments": {
#             "photo": [],
#             "video": [
#                 "..."
#             ],
#             "audio": [],
#             "other": []
#         },
#         "comments": 858,
#         "likes": 1150,
#         "reposts": 371,
#         "views": 518953
#     }

Attachments

You can download gathered attachments to your local system.

from vk_getter import VKGetter
from vk_getter.utils import download, download_all

getter = VKGetter("TOKEN")
posts = getter.get_posts("lol", 150)

# download all of the 4 types
path = "lol"
download_all(posts, path)

# or specify one
download(posts, "photo", path)
download(posts, "video", path)
download(posts, "audio", path)
download(posts, "other", path)

Or you can extract them as links.

from vk_getter import VKGetter
from vk_getter.utils import extract, extract_all

getter = VKGetter("TOKEN")
posts = getter.get_posts("lol", 150)

# extract all of the 4 types
photos, videos, audios, others = extract_all(posts)

# or specify one
photos = extract(posts, "photo")
videos = extract(posts, "video")
audios = extract(posts, "audio")
others = extract(posts, "other")

*Note: do NOT use as_dict in the get_posts method.


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vk_getter-0.0.5.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file vk_getter-0.0.5.tar.gz.

File metadata

  • Download URL: vk_getter-0.0.5.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for vk_getter-0.0.5.tar.gz
Algorithm Hash digest
SHA256 9cf79b50568302fa522d98baaf26fabdb0d186d6e2af010f102ff58bea6dd386
MD5 f24b66eca4043265bccbf449c9611887
BLAKE2b-256 1082587f86c872c9c9f5142483a373d69186f65c802ac8fb131cf99e49bf3f97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page