|
@@ -11,6 +11,7 @@ from PIL import Image
|
|
|
import dataset
|
|
|
from datetime import datetime
|
|
|
from random import randint, choice
|
|
|
+import json
|
|
|
|
|
|
#from setting import rua
|
|
|
|
|
@@ -31,6 +32,23 @@ def restart_browser():
|
|
|
|
|
|
resultdict={'搜尋詞':[],'網域':[],'結果標題':[],'結果網址':[],'結果名次':[]}
|
|
|
|
|
|
+def pickterm(client):
|
|
|
+ ds=db.query('select json from seo.seo_jobs where cust="' + client + '" order by rand() limit 1')
|
|
|
+ #TAG ABOVE AND UNTAG BELOW FOR DEBUG
|
|
|
+ #ds=hhhdb.query('select * from seo.seo_articles where cust=')
|
|
|
+
|
|
|
+ for c in ds:
|
|
|
+ js=json.loads(c['json'])
|
|
|
+ prefix=js['prefix']
|
|
|
+ postfix=js['postfix']
|
|
|
+ domain=js['domain'][0]
|
|
|
+ positive=js['positive']
|
|
|
+ rnd=js['rnd']
|
|
|
+ kw1 = choice(positive)
|
|
|
+ kw2 = choice(rnd)
|
|
|
+ kw = prefix + " " + kw1 + " " + kw2
|
|
|
+ return kw
|
|
|
+
|
|
|
def process_one(term, tgt, n, sr, se):
|
|
|
try:
|
|
|
print(term)
|
|
@@ -105,11 +123,10 @@ def process_one(term, tgt, n, sr, se):
|
|
|
table=db['general_log']
|
|
|
|
|
|
table.insert({'kw':term,'results':count,'url':selection[1],'ranking':selection[2],'title':selection[3],'dt':time_stamp,'type':'vi'})
|
|
|
- time.sleep(30)
|
|
|
+ time.sleep(randint(20,40)) #adjustable
|
|
|
|
|
|
driver.quit()
|
|
|
print('completed')
|
|
|
- time.sleep(randint(20,40)) #adjustable
|
|
|
except:
|
|
|
traceback.print_exc()
|
|
|
|