zoukankan      html  css  js  c++  java
  • 5.2

    selenium无头浏览器,就是使用selenium不弹出浏览器

    from selenium.webdriver import Chrome
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.support.select import Select
    import time
    
    # 准备好参数配置
    opt = Options()
    opt.add_argument("--headless")
    opt.add_argument("--disbale-gpu")
    
    web = Chrome(options=opt)  # 把参数配置设置到浏览器中
    
    web.get("https://www.endata.com.cn/BoxOffice/BO/Year/index.html")
    
    time.sleep(2)
    # # 定位到下拉列表
    # sel_el = web.find_element_by_xpath('//*[@id="OptionDate"]')
    # # 对元素进行包装, 包装成下拉菜单
    # sel = Select(sel_el)
    # # 让浏览器进行调整选项
    # for i in range(len(sel.options)):  # i就是每一个下拉框选项的索引位置
    #     sel.select_by_index(i)  # 按照索引进行切换
    #     time.sleep(2)
    #     table = web.find_element_by_xpath('//*[@id="TableList"]/table')
    #     print(table.text)  # 打印所有文本信息
    #     print("===================================")
    #
    # print("运行完毕.  ")
    # web.close()
    
    
    # 如何拿到页面代码Elements(经过数据加载以及js执行之后的结果的html内容)
    print(web.page_source)
  • 相关阅读:
    移动硬盘文件被恶意隐藏
    asp.net identity UserSecurityStamp 的作用
    Head First Python学习笔记1
    WPF 确认动态加载数据完成
    rust by example 2
    Rust by Example1
    奇葩!把类型转成object
    Lambda高手之路第一部分
    理解Lambda表达式
    贪心算法-找零钱(C#实现)
  • 原文地址:https://www.cnblogs.com/zhaoyids/p/14905293.html
Copyright © 2011-2022 走看看