-
Notifications
You must be signed in to change notification settings - Fork 1
/
find_missing.py
55 lines (53 loc) · 1.49 KB
/
find_missing.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
import time
import selenium
import os
import pymysql
from selenium import webdriver
driver=selenium.webdriver.Chrome()
driver.get("https://photos.google.com/people")
elem=driver.find_element_by_id("identifierId")
elem.send_keys("[email protected]")
driver.find_element_by_xpath("//*[@id='identifierNext']/content/span").click()
time.sleep(2)
elem=driver.find_element_by_xpath("//*[@id='password']/div[1]/div/div[1]/input")
elem.send_keys("password")
time.sleep(2)
driver.find_element_by_xpath("//*[@id='passwordNext']/content/span").click()
time.sleep(10)
conn = pymysql.connect(host='localhost', port=3306, user='root', passwd='', db='photo_db')
cur = conn.cursor()
sql = "SELECT * FROM `details`"
cur.execute(sql)
result=cur.fetchall()
try:
for row in result:
prev_count=int(row[2])
link=row[3]
name=row[1]
idnum=row[0]
driver.get("https://photos.google.com/search/"+link)
#ime.sleep(4)
data=driver.page_source
data=str(data.encode('utf-8'))
f = open("C:/Users/Abhas/Desktop/"+str(row[0])+".html",'w')
f.write(data)
#time.sleep(2)
a=',[27,false,true]'
new_count=data.count(a)
f.close()
#print(prev_count)
#print(new_count)
print(idnum)
if int(new_count)>int(prev_count):
#print ("found1 "+ name)
sql="""UPDATE details SET count=%s where id=%s"""
#print(sql)
cur.execute(sql,(new_count,idnum))
conn.commit()
print("found "+ name),
except:
cur.execute('show profiles')
exit()
finally:
cur.close()
conn.close()