mirror of
https://github.com/NaiboWang/EasySpider.git
synced 2025-04-20 10:05:00 +08:00
Update MyChrome
This commit is contained in:
parent
a90b679673
commit
c749107a6a
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
.temp_to_pub/EasySpider_windows_x64/tasks/234.json
Normal file
1
.temp_to_pub/EasySpider_windows_x64/tasks/234.json
Normal file
File diff suppressed because one or more lines are too long
2
ExecuteStage/.vscode/launch.json
vendored
2
ExecuteStage/.vscode/launch.json
vendored
@ -12,7 +12,7 @@
|
|||||||
"justMyCode": false,
|
"justMyCode": false,
|
||||||
// "args": ["--id", "[7]", "--read_type", "remote", "--headless", "0"]
|
// "args": ["--id", "[7]", "--read_type", "remote", "--headless", "0"]
|
||||||
// "args": ["--id", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"]
|
// "args": ["--id", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"]
|
||||||
"args": ["--id", "[112]", "--headless", "0", "--user_data", "0", "--keyboard", "0"]
|
"args": ["--id", "[119]", "--headless", "0", "--user_data", "0", "--keyboard", "0"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -37,19 +37,21 @@ class MyChrome(webdriver.Chrome):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
find_element = False
|
find_element = False
|
||||||
# 遍历所有的 iframe 并点击里面的元素
|
# 遍历所有的 iframe 并查找里面的元素
|
||||||
for iframe in iframes:
|
for iframe in iframes:
|
||||||
# 切换到 iframe
|
# 切换到 iframe
|
||||||
super().switch_to.default_content()
|
super().switch_to.default_content()
|
||||||
super().switch_to.frame(iframe)
|
super().switch_to.frame(iframe)
|
||||||
self.iframe_env = True
|
self.iframe_env = True
|
||||||
try:
|
try:
|
||||||
# 在 iframe 中查找并点击元素
|
# 在 iframe 中查找元素
|
||||||
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
||||||
element = super().find_element(by=by, value=value)
|
element = super().find_element(by=by, value=value)
|
||||||
find_element = True
|
find_element = True
|
||||||
except NoSuchElementException as e:
|
except NoSuchElementException as e:
|
||||||
print(f"No such element found in the iframe: {str(e)}")
|
print(f"No such element found in the iframe: {str(e)}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception: {str(e)}")
|
||||||
# 完成操作后切回主文档
|
# 完成操作后切回主文档
|
||||||
# super().switch_to.default_content()
|
# super().switch_to.default_content()
|
||||||
if find_element:
|
if find_element:
|
||||||
@ -68,14 +70,14 @@ class MyChrome(webdriver.Chrome):
|
|||||||
# 获取所有的 iframe
|
# 获取所有的 iframe
|
||||||
iframes = super().find_elements(By.CSS_SELECTOR, "iframe")
|
iframes = super().find_elements(By.CSS_SELECTOR, "iframe")
|
||||||
find_element = False
|
find_element = False
|
||||||
# 遍历所有的 iframe 并点击里面的元素
|
# 遍历所有的 iframe 并找到里面的元素
|
||||||
for iframe in iframes:
|
for iframe in iframes:
|
||||||
# 切换到 iframe
|
# 切换到 iframe
|
||||||
try:
|
try:
|
||||||
super().switch_to.default_content()
|
super().switch_to.default_content()
|
||||||
super().switch_to.frame(iframe)
|
super().switch_to.frame(iframe)
|
||||||
self.iframe_env = True
|
self.iframe_env = True
|
||||||
# 在 iframe 中查找并点击元素
|
# 在 iframe 中查找元素
|
||||||
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
||||||
elements = super().find_elements(by=by, value=value)
|
elements = super().find_elements(by=by, value=value)
|
||||||
if len(elements) > 0:
|
if len(elements) > 0:
|
||||||
@ -86,6 +88,8 @@ class MyChrome(webdriver.Chrome):
|
|||||||
return elements
|
return elements
|
||||||
except NoSuchElementException as e:
|
except NoSuchElementException as e:
|
||||||
print(f"No such element found in the iframe: {str(e)}")
|
print(f"No such element found in the iframe: {str(e)}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception: {str(e)}")
|
||||||
if not find_element:
|
if not find_element:
|
||||||
raise NoSuchElementException
|
raise NoSuchElementException
|
||||||
else:
|
else:
|
||||||
@ -117,19 +121,21 @@ if sys.platform != "darwin":
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
find_element = False
|
find_element = False
|
||||||
# 遍历所有的 iframe 并点击里面的元素
|
# 遍历所有的 iframe 并找到里面的元素
|
||||||
for iframe in iframes:
|
for iframe in iframes:
|
||||||
# 切换到 iframe
|
# 切换到 iframe
|
||||||
super().switch_to.default_content()
|
super().switch_to.default_content()
|
||||||
super().switch_to.frame(iframe)
|
super().switch_to.frame(iframe)
|
||||||
self.iframe_env = True
|
self.iframe_env = True
|
||||||
try:
|
try:
|
||||||
# 在 iframe 中查找并点击元素
|
# 在 iframe 中查找元素
|
||||||
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
||||||
element = super().find_element(by=by, value=value)
|
element = super().find_element(by=by, value=value)
|
||||||
find_element = True
|
find_element = True
|
||||||
except NoSuchElementException as e:
|
except NoSuchElementException as e:
|
||||||
print(f"No such element found in the iframe: {str(e)}")
|
print(f"No such element found in the iframe: {str(e)}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception: {str(e)}")
|
||||||
# 完成操作后切回主文档
|
# 完成操作后切回主文档
|
||||||
# super().switch_to.default_content()
|
# super().switch_to.default_content()
|
||||||
if find_element:
|
if find_element:
|
||||||
@ -148,14 +154,14 @@ if sys.platform != "darwin":
|
|||||||
# 获取所有的 iframe
|
# 获取所有的 iframe
|
||||||
iframes = super().find_elements(By.CSS_SELECTOR, "iframe")
|
iframes = super().find_elements(By.CSS_SELECTOR, "iframe")
|
||||||
find_element = False
|
find_element = False
|
||||||
# 遍历所有的 iframe 并点击里面的元素
|
# 遍历所有的 iframe 并查找里面的元素
|
||||||
for iframe in iframes:
|
for iframe in iframes:
|
||||||
# 切换到 iframe
|
# 切换到 iframe
|
||||||
try:
|
try:
|
||||||
super().switch_to.default_content()
|
super().switch_to.default_content()
|
||||||
super().switch_to.frame(iframe)
|
super().switch_to.frame(iframe)
|
||||||
self.iframe_env = True
|
self.iframe_env = True
|
||||||
# 在 iframe 中查找并点击元素
|
# 在 iframe 中查找元素
|
||||||
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
# 在这个例子中,我们查找 XPath 为 '//div[1]' 的元素
|
||||||
elements = super().find_elements(by=by, value=value)
|
elements = super().find_elements(by=by, value=value)
|
||||||
if len(elements) > 0:
|
if len(elements) > 0:
|
||||||
@ -166,6 +172,8 @@ if sys.platform != "darwin":
|
|||||||
return elements
|
return elements
|
||||||
except NoSuchElementException as e:
|
except NoSuchElementException as e:
|
||||||
print(f"No such element found in the iframe: {str(e)}")
|
print(f"No such element found in the iframe: {str(e)}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Exception: {str(e)}")
|
||||||
if not find_element:
|
if not find_element:
|
||||||
raise NoSuchElementException
|
raise NoSuchElementException
|
||||||
else:
|
else:
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<!-- ## 请您Star/Please Star
|
## 请您Star/Please Star
|
||||||
|
|
||||||
如果您觉得此工具不错,请轻轻点击此页面右上角**Star**按钮增加项目曝光度,谢谢!软件完全免费(商用除外),只求大家Star和宣传给其他需要的朋友,谢谢!
|
如果您觉得此工具不错,请轻轻点击此页面右上角**Star**按钮增加项目曝光度,谢谢!软件完全免费(商用除外),只求大家Star和宣传给其他需要的朋友,谢谢!
|
||||||
|
|
||||||
If you think this tool is good, please gently click the **Star** button in the upper right corner at this page to increase the project exposure, thank you! The software is completely free (except for commercial use), only ask everyone to Star and promote it to other friends in need, thank you! -->
|
If you think this tool is good, please gently click the **Star** button in the upper right corner at this page to increase the project exposure, thank you! The software is completely free (except for commercial use), only ask everyone to Star and promote it to other friends in need, thank you!
|
||||||
|
|
||||||
# 易采集/EasySpider: Visual Code-Free Web Crawler
|
# 易采集/EasySpider: Visual Code-Free Web Crawler
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user