无法使用Selenium从网页获取文本

2024-06-11 14:45:35 发布

您现在位置:Python中文网/ 问答频道 /正文

我只是想从主页上抓取所有的文本。此代码不返回任何内容。最终目标是在衬衫图标出现时扫描页面。如果有,点击进入匹配。提前感谢:

First Picture附件是一个匹配的html,我想在页面上循环浏览所有匹配的html Second picture附加的是衬衫图标的html

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.options import Options
from bs4 import BeautifulSoup
import time

PATH = "C:\Program Files (x86)\chromedriver.exe"
chrome_options = Options()
chrome_options.add_argument(" - incognito")
driver = webdriver.Chrome(PATH,options=chrome_options)
driver.get("https://www.flashscore.com/")
driver.implicitly_wait(5)

try:
    main = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.CLASS_NAME, "sportName soccer"))
    )
    print(main.text)
except:
    print("No Text Found")
    driver.quit()

Tags: fromimportsupportbyhtmldriverselenium页面
1条回答
网友
1楼 · 发布于 2024-06-11 14:45:35

However, what I am concerning about is, someone told me that its worst-case is O(n) so it should not be used

他错了

on the other hand, the teacher said that, it does take O(n) for the worst-case, however, it is usually more sensible to perform the analysis using the expected case, O(1).

他是对的。通常将哈希映射视为O(1)O(N)情况很少出现,因此将其纳入广义计算复杂性是不现实的

And this would need to be justified briefly in the report when using the nested hash-map with tree-map in it.

如果他已经告诉你了就不会了。你已经被教导了。你可以假设。其他人都有。你需要说明的是,嵌套的hashmap是O(1),因为O(1)的平方仍然是O(1),hashmap/treemap的情况是O(log(N)),因为O(1)乘以O(log(N))仍然是O(log(N))

相关问题 更多 >