roomInfo
This commit is contained in:
parent
10f5f445db
commit
ecba1fbc31
5
main.py
5
main.py
@ -1,4 +1,5 @@
|
|||||||
import sys
|
import sys
|
||||||
|
import threading
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from scripts import watcher, webdriver
|
from scripts import watcher, webdriver
|
||||||
@ -9,7 +10,9 @@ if __name__ == '__main__':
|
|||||||
print('Invalid url provided, please check...')
|
print('Invalid url provided, please check...')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
webdriver.go(sys.argv[1])
|
t = threading.Thread(target=webdriver.go, args=(sys.argv[1],))
|
||||||
|
t.start()
|
||||||
|
|
||||||
w = watcher.Watcher(directory=config()['watchdog']['dir'])
|
w = watcher.Watcher(directory=config()['watchdog']['dir'])
|
||||||
w.run()
|
w.run()
|
||||||
|
|
Binary file not shown.
@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from protobuf import message_pb2
|
from protobuf import message_pb2
|
||||||
|
|
||||||
from messages.member import MemberMessage
|
from messages.member import MemberMessage
|
||||||
@ -29,6 +30,8 @@ def unpackMsgBin(filepath):
|
|||||||
decodeMsg(response.messages)
|
decodeMsg(response.messages)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pass
|
pass
|
||||||
|
finally:
|
||||||
|
os.remove(filepath)
|
||||||
|
|
||||||
def decodeMsg(messages):
|
def decodeMsg(messages):
|
||||||
for message in messages:
|
for message in messages:
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -39,5 +39,6 @@ class Handler(FileSystemEventHandler):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
elif event.event_type == 'created':
|
elif event.event_type == 'created':
|
||||||
|
print('here')
|
||||||
q.put(event.src_path)
|
q.put(event.src_path)
|
||||||
|
|
||||||
|
@ -1,15 +1,21 @@
|
|||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
from selenium import webdriver
|
from selenium import webdriver
|
||||||
from selenium.webdriver.chrome.options import Options
|
from selenium.webdriver.chrome.options import Options
|
||||||
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
|
||||||
from selenium.webdriver.common.proxy import Proxy, ProxyType
|
from selenium.webdriver.common.proxy import Proxy, ProxyType
|
||||||
|
from selenium.webdriver.common.by import By
|
||||||
|
from selenium.webdriver.support.ui import WebDriverWait
|
||||||
|
from selenium.webdriver.support.expected_conditions import presence_of_element_located
|
||||||
|
|
||||||
from config.helper import config
|
from config.helper import config
|
||||||
|
from store.mongo import MongoStore
|
||||||
|
|
||||||
def go(url):
|
def go(url):
|
||||||
chrome_options = Options()
|
chrome_options = Options()
|
||||||
chrome_options.add_argument('--proxy-server=%s' % config()['webdriver']['proxy'])
|
chrome_options.add_argument('--proxy-server=%s' % config()['webdriver']['proxy'])
|
||||||
# chrome_options.add_argument('--headless')
|
# chrome_options.add_argument('--headless')
|
||||||
chrome_options.add_experimental_option('detach', True)
|
|
||||||
|
|
||||||
proxy = Proxy()
|
proxy = Proxy()
|
||||||
proxy.proxy_type = ProxyType.MANUAL
|
proxy.proxy_type = ProxyType.MANUAL
|
||||||
@ -19,6 +25,33 @@ def go(url):
|
|||||||
capabilities = DesiredCapabilities.CHROME
|
capabilities = DesiredCapabilities.CHROME
|
||||||
proxy.add_to_capabilities(capabilities)
|
proxy.add_to_capabilities(capabilities)
|
||||||
|
|
||||||
driver = webdriver.Chrome(options=chrome_options, desired_capabilities=capabilities, executable_path=config()['webdriver']['bin'])
|
with webdriver.Chrome(options=chrome_options,
|
||||||
|
desired_capabilities=capabilities,
|
||||||
|
executable_path=config()['webdriver']['bin']
|
||||||
|
) as driver:
|
||||||
|
wait = WebDriverWait(driver, 10)
|
||||||
|
|
||||||
|
driver.implicitly_wait(24 * 60 * 60)
|
||||||
|
|
||||||
|
driver.get(url)
|
||||||
|
|
||||||
|
first_result = wait.until(presence_of_element_located((By.ID, "RENDER_DATA")))
|
||||||
|
json_str = requests.utils.unquote(first_result.get_attribute("textContent"))
|
||||||
|
json_obj = json.loads(json_str)
|
||||||
|
|
||||||
|
roomInfo = json_obj['initialState']['roomStore']['roomInfo']
|
||||||
|
|
||||||
|
store = MongoStore()
|
||||||
|
store.set_collection('room')
|
||||||
|
store.insert_one({
|
||||||
|
'roomId': roomInfo['roomId'],
|
||||||
|
'web_rid': roomInfo['web_rid'],
|
||||||
|
'title': roomInfo['room']['title'],
|
||||||
|
'user_count_str': roomInfo['room']['user_count_str'],
|
||||||
|
'cover': roomInfo['room']['cover']['url_list'][0],
|
||||||
|
'admin_user_ids': roomInfo['room']['admin_user_ids'],
|
||||||
|
'owner': roomInfo['room']['owner']
|
||||||
|
})
|
||||||
|
|
||||||
|
wait.until(presence_of_element_located((By.CLASS_NAME, "oSu9Aw19")))
|
||||||
|
|
||||||
driver.get(url)
|
|
||||||
|
Reference in New Issue
Block a user