标签:tps 网易云 tle style com ted 输出 common click
from selenium import webdriver from selenium.webdriver import ActionChains from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC browser = webdriver.Chrome() browser.get(‘https://music.163.com/#‘) ranke = browser.find_element_by_xpath(‘//*[@id="g_nav2"]/div/ul/li[2]/a/em‘) # 查到排行榜按钮 ranke.click() # 点击 frame = browser.find_element_by_id(‘g_iframe‘) # 查询frame browser.switch_to.frame(frame) # 切换frame ranke_table = browser.find_element_by_tag_name(‘tbody‘) # 查询表 trs = ranke_table.find_elements_by_tag_name(‘tr‘) # 查询行 for tr in trs: # 遍历行 name = tr.find_element_by_tag_name(‘b‘) # 查到title print(name.get_attribute(‘title‘)) # 输出title browser.switch_to.parent_frame() # 切换到frame上级 browser.find_element_by_xpath(‘//*[@id="g_nav2"]/div/ul/li[1]/a/em‘).click() # 查到推荐按钮并点击
标签:tps 网易云 tle style com ted 输出 common click
原文地址:https://www.cnblogs.com/chenyishi/p/10620898.html