|
@@ -38,7 +38,7 @@ def empty_query(q):
|
|
|
driver.get(googleurl)
|
|
|
time.sleep(3)
|
|
|
|
|
|
-def process_query(url, query):
|
|
|
+def process_query(url, cust, query):
|
|
|
sleepoffset = 0
|
|
|
global driver
|
|
|
driver.get('https://www.google.com?num=100')
|
|
@@ -89,6 +89,9 @@ def process_query(url, query):
|
|
|
webdriver.ActionChains(driver).move_to_element(el).perform()
|
|
|
webdriver.ActionChains(driver).move_to_element(el).click().perform()
|
|
|
print("Rank: " + str(n))
|
|
|
+ time_stamp = datetime.fromtimestamp(time.time())
|
|
|
+ time_stamp = time_stamp.strftime("%Y-%m-%d %H:%M:%S")
|
|
|
+ db['general_log'].insert({"time_stamp": time_stamp, "query": query, "url": href, "content": txt, "client": cust})
|
|
|
duration = random.randint(40,60)
|
|
|
time.sleep(duration)
|
|
|
|
|
@@ -97,7 +100,7 @@ def process_query(url, query):
|
|
|
|
|
|
|
|
|
|
|
|
-def run_once(url, query):
|
|
|
+def run_once(url, cust, query):
|
|
|
global driver
|
|
|
result=[]
|
|
|
options = webdriver.ChromeOptions()
|
|
@@ -113,19 +116,19 @@ def run_once(url, query):
|
|
|
driver.delete_all_cookies()
|
|
|
driver.set_window_size(1400,1000)
|
|
|
|
|
|
- statuscode = process_query(url, query)
|
|
|
+ statuscode = process_query(url, cust, query)
|
|
|
driver.quit()
|
|
|
|
|
|
return statuscode
|
|
|
|
|
|
#execution starts here
|
|
|
|
|
|
-def execute(url, query):
|
|
|
+def execute(url, cust, query):
|
|
|
print("Ctrl+C or Ctrl+Z to stop.")
|
|
|
statuscode = 0
|
|
|
st = timeit.default_timer()
|
|
|
try:
|
|
|
- statuscode = run_once(url, query)
|
|
|
+ statuscode = run_once(url, cust, query)
|
|
|
except:
|
|
|
traceback.print_exc()
|
|
|
timetaken = timeit.default_timer()-st
|