Last active
April 19, 2020 08:05
-
-
Save andy23512/e1dab849c1eb10ee8bf3bcc8f3756835 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.common.action_chains import ActionChains | |
import time | |
driver = webdriver.Chrome() | |
action = ActionChains(driver); | |
driver.get("https://aqicn.org/city/shanghai/hk") | |
driver.execute_script("window.scrollTo(0, 2500);") | |
driver.implicitly_wait(10) | |
time.sleep(10) | |
element = driver.find_element_by_xpath("//*[@class='yearly-aqi']") | |
species = element.find_elements_by_xpath("//ul//li") | |
for specie in species: | |
print(specie.get_attribute("innerText")) | |
action.move_to_element(specie).perform() | |
time.sleep(2) | |
element = driver.find_element_by_xpath("//*[@class='yearly-aqi']") | |
print(element.get_attribute("innerHTML")) | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment