-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathgetGroupTitles.py
49 lines (40 loc) · 1.57 KB
/
getGroupTitles.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
# script to just open one whatsapp chat group after another and store their titles.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import sys,time,random
from selenium.webdriver.remote.remote_connection import LOGGER
import logging,os
LOGGER.setLevel(logging.WARNING)
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
# encoding=utf8
reload(sys)
sys.setdefaultencoding('utf8')
# Replace below path with the absolute path
# to chromedriver in your computer
driver = webdriver.Chrome();
#driver = webdriver.Firefox(executable_path='/Users/kgarimella/Downloads/geckodriver');
driver.set_page_load_timeout(3)
filename = "whatsapp_group_links.txt";
f = open(filename); # file containing the links to the whatsapp groups
lines = f.readlines();
count = 1;
#driver.get("https://web.whatsapp.com");
#wait = WebDriverWait(driver, 600)
#time.sleep(15); # sleep for some time while I use my phone to scan the QR code
for line in lines:
try:
line = line.strip().strip("/");
group_id = line.split("/")[-1];
print >> sys.stderr, "processing", line;
driver.get(line);
group_info = driver.find_element_by_css_selector(".block__title");
title = group_info.get_attribute('innerHTML');
print group_id + "\t" + title;
sleep_time = random.randint(1,5);
time.sleep(sleep_time);
except:
print >> sys.stderr, "fx";
pass;