zoukankan      html  css  js  c++  java
  • selenium-百度新歌榜

    打开百度新歌榜, http://music.baidu.com/top/new

    在排名前50的歌曲中,找出其中排名上升的歌曲和演唱者

    from selenium import webdriver
    #chrome驱动 执行该步骤时selenium会去到指定路径将chrome driver执行起来
    driver = webdriver.Chrome(r"D:for myselfGoogleChromeApplicationchromedriver.exe")
    driver.implicitly_wait(10)#隐式等待
    #get方法 打开指定网址
    driver.get('http://music.baidu.com/top/new')

    div = driver.find_element_by_id("songListWrapper")
    ul = div.find_element_by_tag_name("ul")
    liList = ul.find_elements_by_tag_name('li')
    for li in liList:
    uptags = li.find_elements_by_class_name("up")
    if uptags:
    title = li.find_elements_by_class_name('song-title ')
    titleStr = title.find_element_by_tag_name("a").text

    authorsStr = li.find_element_by_class_name("author_list").text
    print('{:10s}:{}'.format(titleStr, authorsStr))#对齐格式 宽度为10

    driver.quit()
  • 相关阅读:
    [loj6484]LJJ爱数书
    [loj3163]动态直径
    [loj2983]数树
    [luogu3785]文本校正
    [loj2572]字符串
    [loj3103]节日庆典
    [atARC118F]Growth Rate
    [atARC118E]Avoid Permutations
    [cf794G]Replace All
    [cf756E]Byteland coins
  • 原文地址:https://www.cnblogs.com/iamshasha/p/11103422.html
Copyright © 2011-2022 走看看