|
@@ -20,6 +20,7 @@ import pandas as pd
|
|
|
import time
|
|
|
import json
|
|
|
import re
|
|
|
+import sys
|
|
|
# import pyautogui as pag
|
|
|
|
|
|
def serive_create(profilepath):
|
|
@@ -39,10 +40,12 @@ def serive_create(profilepath):
|
|
|
|
|
|
return driver
|
|
|
|
|
|
-def brower_start():
|
|
|
+def brower_start(port):
|
|
|
options = webdriver.ChromeOptions()
|
|
|
+# browser = webdriver.Chrome(options=options)
|
|
|
+
|
|
|
browser = webdriver.Remote(
|
|
|
- command_executor='http://192.53.174.202:4444/wd/hub',
|
|
|
+ command_executor='http://127.0.0.1:'+str(port)+'/wd/hub',
|
|
|
desired_capabilities=options.to_capabilities()
|
|
|
)
|
|
|
return browser
|
|
@@ -455,12 +458,19 @@ def main():
|
|
|
db = DA.mysql_connect(MYSQL_CONFIG, DB_NAME)
|
|
|
url_pd = get_not_cralwer_url(keyword)
|
|
|
|
|
|
- print('drvier start...')
|
|
|
- # driver = brower_start()
|
|
|
+
|
|
|
+ keyword = '麻辣火鍋'
|
|
|
+ if len(sys.argv) >1:
|
|
|
+ keyword=sys.argv[1]
|
|
|
+ port=4444
|
|
|
+ if len(sys.argv) >2:
|
|
|
+ port=int(sys.argv[2])
|
|
|
|
|
|
+ print('drvier start...')
|
|
|
+ driver = brower_start(port)
|
|
|
# driver = serive_create('Profile 1')
|
|
|
- profilepath = 'Profile 1'
|
|
|
- driver = serive_create_linux(profilepath)
|
|
|
+ # profilepath = 'Profile 1'
|
|
|
+ # driver = serive_create_linux(profilepath)
|
|
|
|
|
|
for key, row in url_pd.iterrows():
|
|
|
try:
|
|
@@ -506,8 +516,8 @@ def main():
|
|
|
error_table_col = ['name', 'lon', 'lat', 'keyword', 'item_url', 'crawler_date']
|
|
|
data_select_insert(db, 'error_list', error_table_col, row)
|
|
|
driver.close()
|
|
|
- # driver = brower_start()
|
|
|
- driver = serive_create_linux(profilepath)
|
|
|
+ driver = brower_start(port)
|
|
|
+ # driver = serive_create_linux(profilepath)
|
|
|
|
|
|
|
|
|
|