-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvk_scraping.py
62 lines (49 loc) · 1.73 KB
/
vk_scraping.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import re
from selenium.webdriver.common.by import By
import vk as api_key
import sqlite3
import misc
from credentials import vk
# Переходим на страницу авторизации
driver = misc.web_surfing()
driver.get(f"https://oauth.vk.com/authorize?client_id={vk['application']}]&response_type=token")
# Заполняем форму авторизации
driver.find_element(By.NAME, 'email').send_keys(f"{vk['login']}")
driver.find_element(By.NAME, 'pass').send_keys(f"{vk['password']}")
driver.find_element(By.ID, 'install_allow').click()
token = re.findall('[a-z0-9]{10,}', driver.current_url)[0]
driver.quit()
api = api_key.Api(token)
users = set()
groups = [
'club85955762', # CASLON MUSIC / what.cd
'invitesmag', # Купля-Продажа обмен инвайтами (приглашениями)
'flac_music', # Waffles.CH & What.CD (Apollo.rip & Redacted.ch)
'jpopsuki', # Jpopsuki
'btinvite', # БитТОРРЕНТ трекеры – обмен инвайтами, помощь
'club3111532', # Soulseek
'deepbassnine', # deepbassnine.com (db9)
'club9680876' # karagarga
]
for item in [group for group in api.get_groups(groups)]:
for i in item.get_members():
if i.can_write_private_message is True and i.is_friend is False:
users.add(
(
i.id,
i.first_name,
i.last_name
)
)
table = 'vk'
users_db = sqlite3.connect('users.db')
users_db.executemany(f"""
INSERT OR IGNORE INTO {table} (
id,
first_name,
last_name
)
values(?, ?, ?)
""", users)
users_db.commit()
misc.count_is_null(table)