ソースを参照

newBodyText Update

pull/254/head
naibo 9ヶ月前
コミット
50949d4f8c
5個のファイルの変更10行の追加4行の削除
  1. +1
    -0
      ElectronJS/tasks/278.json
  2. +1
    -0
      ElectronJS/tasks/292.json
  3. +1
    -1
      ExecuteStage/.vscode/launch.json
  4. +6
    -2
      ExecuteStage/easyspider_executestage.py
  5. +1
    -1
      ExecuteStage/myCode.py

+ 1
- 0
ElectronJS/tasks/278.json
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1
- 0
ElectronJS/tasks/292.json
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 1
- 1
ExecuteStage/.vscode/launch.json ファイルの表示

@ -12,7 +12,7 @@
"justMyCode": false,
// "args": ["--ids", "[7]", "--read_type", "remote", "--headless", "0"]
// "args": ["--ids", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"]
"args": ["--ids", "[49]", "--headless", "0", "--user_data", "0", "--keyboard", "0",
"args": ["--ids", "[53]", "--headless", "0", "--user_data", "0", "--keyboard", "0",
"--read_type", "remote"]
// "args": "--ids '[97]' --user_data 1 --server_address http://localhost:8074 --config_folder '/Users/naibo/Documents/EasySpider/ElectronJS/' --headless 0 --read_type remote --config_file_name config.json --saved_file_name"
}

+ 6
- 2
ExecuteStage/easyspider_executestage.py ファイルの表示

@ -1109,7 +1109,12 @@ class BrowserThread(Thread):
try:
finished = False
if node["parameters"]["exitCount"] == 0:
newBodyText = self.browser.find_element(By.XPATH, node["parameters"]["exitElement"], iframe=node["parameters"]["iframe"]).text
# newBodyText = self.browser.find_element(By.XPATH, node["parameters"]["exitElement"], iframe=node["parameters"]["iframe"]).text
# 用find_elements获取所有匹配到的文本
exitElements = self.browser.find_elements(By.XPATH, node["parameters"]["exitElement"], iframe=node["parameters"]["iframe"])
newBodyText = ""
for exitElement in exitElements:
newBodyText += exitElement.text
if node["parameters"]["iframe"]: # 如果标记了iframe
iframes = self.browser.find_elements(
By.CSS_SELECTOR, "iframe", iframe=False)
@ -1120,7 +1125,6 @@ class BrowserThread(Thread):
By.CSS_SELECTOR, "body").text # 用super调用父类的方法
newBodyText += iframe_text
self.browser.switch_to.default_content()
if newBodyText == bodyText: # 如果页面内容无变化
self.print_and_log("页面已检测不到新内容,停止循环。")
self.print_and_log(

+ 1
- 1
ExecuteStage/myCode.py ファイルの表示

@ -37,7 +37,7 @@ def test(n = 0):
# 异常捕获 | Exception capture
try:
# 使用XPath定位元素并点击浏览器中元素 | Use XPath to locate the element and click the element in the browser
element = self.browser.find_element(By.XPATH, "//*[contains(@class, 'LeftSide_menu_list__qXCeM')]/div[1]/a[1]") # 这里请忽略IDE的报错,因为代码是嵌入到程序中的,IDE无法识别self变量和By变量是正常的 | Please ignore the error reported by the IDE, because the code is embedded in the program, and the IDE cannot recognize that the self variable and By variable are normal
element = self.browser.find_element(By.XPATH, "//*[contains(@class, 'LeftSide_menu_list__qXCeM')]/div[1]/a[1]") # 这里请忽略IDE语法报错如找不到self的报错,因为代码是嵌入到程序中的,IDE无法识别self变量和By变量是正常的 | Please ignore the warning reported by the IDE such as "'self' is not defined", because the code is embedded in the program, and the IDE cannot recognize that the self variable and By variable are normal
actions = ActionChains(self.browser)
actions.click(element).perform()
print("点击成功|Click success")

読み込み中…
キャンセル
保存