mirror of
https://github.com/NaiboWang/EasySpider.git
synced 2025-04-20 04:39:57 +08:00
Change Database config name
This commit is contained in:
parent
9a2311b820
commit
35b9494d42
@ -294,7 +294,7 @@ exports.start = function(port = 8074) {
|
||||
const config = {
|
||||
host: "localhost",
|
||||
port: 3306,
|
||||
user: "your_username",
|
||||
username: "your_username",
|
||||
password: "your_password",
|
||||
database: "your_database"
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ from PIL import Image
|
||||
# import uuid
|
||||
from threading import Thread, Event
|
||||
from myChrome import MyChrome, MyUCChrome
|
||||
from utils import check_pause, download_image, get_output_code, isnull, lowercase_tags_in_xpath, myMySQL, new_line, on_press_creator, on_release_creator, write_to_csv, write_to_excel
|
||||
from utils import download_image, get_output_code, isnull, lowercase_tags_in_xpath, myMySQL, new_line, on_press_creator, on_release_creator, write_to_csv, write_to_excel
|
||||
desired_capabilities = DesiredCapabilities.CHROME
|
||||
desired_capabilities["pageLoadStrategy"] = "none"
|
||||
|
||||
@ -1501,6 +1501,9 @@ if __name__ == '__main__':
|
||||
browser_t = MyChrome(
|
||||
options=options, chrome_options=option, executable_path=driver_path)
|
||||
elif cloudflare == 1:
|
||||
if sys.platform == "linux":
|
||||
import ssl
|
||||
ssl._create_default_https_context = ssl._create_unverified_context # 忽略证书验证
|
||||
browser_t = MyUCChrome(
|
||||
options=options, chrome_options=option, driver_executable_path=driver_path)
|
||||
print("Pass Cloudflare Mode")
|
||||
|
@ -8,3 +8,4 @@ openpyxl==3.1.2
|
||||
pymysql==1.1.0
|
||||
lxml==4.9.2
|
||||
pynput==1.7.6
|
||||
undetected-chromedriver==3.4.7
|
@ -7,7 +7,7 @@ import os
|
||||
import re
|
||||
import time
|
||||
import uuid
|
||||
import keyboard
|
||||
# import keyboard
|
||||
from openpyxl import Workbook, load_workbook
|
||||
import requests
|
||||
from urllib.parse import urlparse
|
||||
@ -75,20 +75,20 @@ def on_release_creator(event, press_time):
|
||||
return on_release
|
||||
|
||||
|
||||
def check_pause(key, event):
|
||||
while True:
|
||||
if keyboard.is_pressed(key): # 按下p键,暂停程序
|
||||
if event._flag == False:
|
||||
print("任务执行中,长按p键暂停执行。")
|
||||
print("Task is running, long press 'p' to pause.")
|
||||
# 设置Event的值为True,使得线程b可以继续执行
|
||||
event.set()
|
||||
else:
|
||||
# 设置Event的值为False,使得线程b暂停执行
|
||||
print("任务已暂停,长按p键继续执行...")
|
||||
print("Task paused, press 'p' to continue...")
|
||||
event.clear()
|
||||
time.sleep(1) # 每秒检查一次
|
||||
# def check_pause(key, event):
|
||||
# while True:
|
||||
# if keyboard.is_pressed(key): # 按下p键,暂停程序
|
||||
# if event._flag == False:
|
||||
# print("任务执行中,长按p键暂停执行。")
|
||||
# print("Task is running, long press 'p' to pause.")
|
||||
# # 设置Event的值为True,使得线程b可以继续执行
|
||||
# event.set()
|
||||
# else:
|
||||
# # 设置Event的值为False,使得线程b暂停执行
|
||||
# print("任务已暂停,长按p键继续执行...")
|
||||
# print("Task paused, press 'p' to continue...")
|
||||
# event.clear()
|
||||
# time.sleep(1) # 每秒检查一次
|
||||
|
||||
|
||||
def download_image(url, save_directory):
|
||||
@ -223,12 +223,13 @@ class myMySQL:
|
||||
config = json.load(f)
|
||||
host = config["host"]
|
||||
port = config["port"]
|
||||
user = config["user"]
|
||||
user = config["username"]
|
||||
passwd = config["password"]
|
||||
db = config["database"]
|
||||
except:
|
||||
except Exception as e:
|
||||
print("读取配置文件失败,请检查配置文件:"+config_file+"是否存在。")
|
||||
print("Failed to read configuration file, please check if the configuration file: "+config_file+" exists.")
|
||||
print(e)
|
||||
try:
|
||||
self.conn = pymysql.connect(
|
||||
host=host, port=port, user=user, passwd=passwd, db=db)
|
||||
|
Loading…
x
Reference in New Issue
Block a user