|
@@ -21,7 +21,7 @@ import codecs
|
|
|
import random
|
|
|
import os
|
|
|
import time
|
|
|
-
|
|
|
+import dataset
|
|
|
|
|
|
driver=None
|
|
|
headers = {
|
|
@@ -134,26 +134,19 @@ def run_once(url):
|
|
|
|
|
|
portnum=sys.argv[1]
|
|
|
|
|
|
-fpath=__file__
|
|
|
-elmts=fpath.split('\\')
|
|
|
-fpath=fpath.replace(elmts[-1],'urls.csv')
|
|
|
-
|
|
|
os.system('docker restart p'+str(portnum))
|
|
|
time.sleep(4)
|
|
|
|
|
|
|
|
|
|
|
|
+lst=[]
|
|
|
|
|
|
-print(fpath)
|
|
|
+db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
|
|
|
|
|
|
-lst=[]
|
|
|
+cursor=db.query('SELECT * FROM columnids order by rand()')
|
|
|
+for c in cursor:
|
|
|
+ lst.append('https://www.hhh.com.tw/columns/detail/'+str(c['cid'])+'/index.php')
|
|
|
|
|
|
-fr=codecs.open(fpath,'r','utf-8')
|
|
|
-lines=fr.readlines()
|
|
|
-for l in lines:
|
|
|
- elmts=l.split(',')
|
|
|
- lst.append('https://www.hhh.com.tw'+elmts[0])
|
|
|
-fr.close()
|
|
|
|
|
|
#lst=['https://www.hhh.com.tw/columns/detail/3427/index.php']
|
|
|
#for i in range(20):
|