-
Notifications
You must be signed in to change notification settings - Fork 1
/
get_and_post.py
36 lines (29 loc) · 1.18 KB
/
get_and_post.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
import config
import requests
from request_top10 import get_data, post_data
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.options import Options
import os
import boot
from boot import socketio
def run():
options = Options()
options.headless = True
driver = webdriver.Firefox(options=options, executable_path='%s/geckodriver' % os.getcwd())
req = requests.get(config.GITHUB_ACCOUNTS)
accounts = req.content
acc_split = accounts.splitlines()
acc_normal = list(filter(lambda item: not item.endswith(b'/'), acc_split))
acc_not_normal = list(filter(lambda item: item.endswith(b'/'), acc_split))
acc_normalized = [item[:-1] for item in acc_not_normal]
map_normal = [b''.join(item.split(b'/')[-1].split(b' ')).decode() for item in acc_normal]
map_normalized = [b''.join(item.split(b'/')[-1].split(b' ')).decode() for item in acc_normalized]
map_normal.extend(map_normalized)
datas = [get_data(driver, user) for user in map_normal]
print(datas)
print("sending data to %s/broadcast-top10" % config.HOST)
requests.post("%s/broadcast-top10" % config.HOST, json=datas)
driver.quit()
if __name__ == "__main__":
run()