| 
					
				 | 
			
			
				@@ -149,4 +149,46 @@ def execute(url, cust, query): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     print("Ctrl+C or Ctrl+Z to stop now.") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     print("You have " + str(10 + extrasleep) + " seconds.") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     time.sleep(10 + extrasleep) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    return statuscode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return statuscode 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def reset(client): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    ds=db.query('select * from seo.seo_articles where cust="' + client + '"') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #TAG ABOVE AND UNTAG BELOW FOR DEBUG 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    #ds=hhhdb.query('select * from seo.seo_articles where cust=') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    data=[] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    for i in ds: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if i['weight']!=0: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for j in range(i['weight']): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                data.append([i['kw'].replace('\xa0',' '),i['cust'].replace('\xa0',' '),i['url']]) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    random.shuffle(data) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+def run(client): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    runcount=0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    while True: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        try: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print("Gathering data...") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            data = reset(client) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print('Data collected') 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dataok = 1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        except: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            dataok = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            print("Error while collecting data.") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if dataok == 1: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            for i in range(10): 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                print("Run " + str(runcount+1)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                target = random.choice(data) # START HERE 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                target_kw = target[0] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                cust = target[1] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                target_url = target[2] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                print(target_kw) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                print(cust) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                print(target_url) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                statuscode = execute(target_url, cust, target_kw) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if statuscode == 444: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    print("Completed ", runcount, " times before being caught") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    time.sleep(300) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    runcount+=1 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        else: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            time.sleep(60) 
			 |