当前位置:   article > 正文

Selenium in Python - 查询与取值_python selenium 模糊查询

python selenium 模糊查询
import random

from selenium import webdriver
import time


def view(browser, blog):
    browser.maximize_window()
    browser.get(blog)
    time.sleep(5)

    urls = []
    html_as = browser.find_elements_by_css_selector("li.blog-unit a")
    for html_a in html_as:
        urls.append(html_a.get_attribute("href"))

    print urls

    for html in urls:
        try:
            browser.get(html)
            time.sleep(random.randint(3, 5))
        except Exception, e:
            print e
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/正经夜光杯/article/detail/878454
推荐阅读
相关标签
  

闽ICP备14008679号