zoukankan      html  css  js  c++  java
  • selenium基本操作

    firefox设置selenium无界面

    
    from selenium import webdriver
    options = webdriver.FirefoxOptions()
    options.set_headless()
    driver=webdriver.Firefox(firefox_options=options)
    driver.get("http://www.baidu.com")
    print(driver.page_source)
    driver.close()
    

    selenuim设置cookie

    删除原来的cookie

    brower.delete_all_cookies() 
    

    携带cookie打开

    brower.add_cookie({'name':'python', 'value':'spider'})
    

    selenium设置phantomjs-图片不加载

    SERVICE_ARGS = ['--disk-cache=true', '--load-images=false'] 
    
    brower = webdriver.PhantomJS(service_args=SERVICE_ARGS)
    

    selenium设置请求头

    options.add_argument('lang=zh_CN.UTF-8')
    

    更换UserAgent

    ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.101 Safari/537.36'
    options.add_argument('user-agent="%s"' % ua)
    
  • 相关阅读:
    JavaEE思维导图
    JAVA EE期末项目-企业论坛
    RPC
    SQL、HQL、JPQL、CQL的对比
    eqauls和hashCode的对比
    关于JSON
    JavaServer Faces标准请求/响应周期
    Applets
    Ajax
    Async分析
  • 原文地址:https://www.cnblogs.com/Jaryer/p/13603051.html
Copyright © 2011-2022 走看看