We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
环境: Linux 5.4.162 #0 SMP Mon Jan 17 04:29:05 2022 x86_64 GNU/Linux Python 3.11.9 DrissionPage 4.0.4.21
测试代码如下 :
from DrissionPage import ChromiumPage from DrissionPage import ChromiumOptions import logging logger_format = '%(asctime)s %(levelname)-8s %(message)s' logging.basicConfig( format=logger_format, level='DEBUG', datefmt='%Y-%m-%d %H:%M:%S' ) co = ChromiumOptions() co.set_argument('--incognito') co.set_argument('--no-sandbox') co.set_headless(True) page = ChromiumPage(co) url = "https://www.fanfiction.net/s/14145272/1/In-Your-Wildest-Dreams" logging.debug(f'Navigating to... {url}') page.get(url) selector = ['#challenge-running', '#cf-challenge-running', '#cf-please-wait'] for selector in selector: logging.debug("checking selector: " + selector + " ...") found_elements = page.eles(selector) logging.debug("found elements: " + str(found_elements))
执行结果:
2024-05-01 14:27:42 DEBUG Starting new HTTP connection (1): 127.0.0.1:9222 2024-05-01 14:27:42 DEBUG http://127.0.0.1:9222 "GET /json HTTP/1.1" 200 1196 2024-05-01 14:27:42 DEBUG Starting new HTTP connection (1): 127.0.0.1:9222 2024-05-01 14:27:42 DEBUG http://127.0.0.1:9222 "GET /json/version HTTP/1.1" 200 404 2024-05-01 14:27:42 DEBUG Starting new HTTP connection (1): 127.0.0.1:9222 2024-05-01 14:27:42 DEBUG http://127.0.0.1:9222 "GET /json HTTP/1.1" 200 1196 2024-05-01 14:27:42 DEBUG Navigating to... https://www.fanfiction.net/s/14145272/1/In-Your-Wildest-Dreams 2024-05-01 14:27:45 DEBUG checking selector: #challenge-running ... 2024-05-01 14:27:45 DEBUG found elements: [<ChromiumElement h2 id='challenge-running' class='h2'>] 2024-05-01 14:27:45 DEBUG checking selector: #cf-challenge-running ... 2024-05-01 14:27:55 DEBUG found elements: [] 2024-05-01 14:27:55 DEBUG checking selector: #cf-please-wait ... 2024-05-01 14:28:05 DEBUG found elements: []
可以看到查找#cf-challenge-running和#cf-please-wait这种不存在的元素时,结果日志输出需要 10 秒钟,但查找页面存在的元素#challenge-running时,执行就很快,不到 1 秒,请问这个是什么原因导致的?还能优化吗?
#cf-challenge-running
#cf-please-wait
#challenge-running
The text was updated successfully, but these errors were encountered:
page.ele()是不是有个timeout参数?
Sorry, something went wrong.
可以切换到 s 模式解决 https://drissionpage.cn/get_start/concept#-s-%E6%A8%A1%E5%BC%8F
No branches or pull requests
环境:
Linux 5.4.162 #0 SMP Mon Jan 17 04:29:05 2022 x86_64 GNU/Linux
Python 3.11.9
DrissionPage 4.0.4.21
测试代码如下 :
执行结果:
可以看到查找
#cf-challenge-running
和#cf-please-wait
这种不存在的元素时,结果日志输出需要 10 秒钟,但查找页面存在的元素#challenge-running
时,执行就很快,不到 1 秒,请问这个是什么原因导致的?还能优化吗?The text was updated successfully, but these errors were encountered: