我想在现有网页上循环执行某些操作
答案 0 :(得分:0)
硒将为您做所有这一切,还有更多!以下是使用Firefox的示例;您可以轻松使用Chrome,IE等。
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
wd = webdriver.Firefox(executable_path="C:/Utility/geckodriver.exe", firefox_profile=profile)
url = "https://www.google.com/"
wd.get(url)
# download geckodriver for windows 64-bit from here
# https://github.com/mozilla/geckodriver/releases
您将需要专注于这样的事情:
find_element_by_class_name(name)
Finds an element by class name.
Args:
name: The class name of the element to find.
Returns:
WebElement - the element if it was found
Raises:
NoSuchElementException - if the element wasn’t found
Usage:
element = driver.find_element_by_class_name('foo')
有关更多信息,请参见下面的链接。