zoukankan      html  css  js  c++  java
  • 【python】跳过验证直接登陆-把cookie导入excl表格然后调用

    *********************************把cookie写入xlsx
    import time
    import xlwt
    from webdriver_manager.chrome import ChromeDriverManager
    from selenium import webdriver

    import time
    import xlwt
    from webdriver_manager.chrome import ChromeDriverManager
    from seleniumwire import webdriver

    #前置部署
    driver=webdriver.Chrome(ChromeDriverManager().install())
    driver.implicitly_wait(10)
    driver.get("https://www.pangle.cn/")
    #30秒时间手动登陆够不够
    time.sleep(60)
    #把新生成的cookie写入xlsx
    workbook=xlwt.Workbook(encoding='utf-8')
    worksheet=workbook.add_sheet('sheet1')
    worksheet.write(0,0,'name')
    worksheet.write(0,1,'value')
    worksheet.write(0,2,'domain')
    worksheet.write(0,3,'path')
    i=1
    for cookie in driver.get_cookies():
    worksheet.write(i,0,cookie['name'])
    worksheet.write(i,1,cookie['value'])
    worksheet.write(i,2,cookie['domain'])
    worksheet.write(i,3,cookie['path'])
    i=i+1
    workbook.save('cookie.xlsx')
    #退出页面
    driver.quit()
    *****************************************调用
    import xlrd

    wb=xlrd.open_workbook('cookie.xlsx')
    sheel=wb.sheet_by_name('sheet1')
    for row in range(1,sheel.nrows):
    self.driver.add_cookie({'name':sheel.cell_value(row,0),'value':sheel.cell_value(row,1),'domain':sheel.cell_value(row,2),'path':sheel.cell_value(row,3)})
    self.driver.refresh()
  • 相关阅读:
    Java中HashMap底层实现原理(JDK1.8)源码分析
    java io系列01之 "目录"
    数据结构与算法系列 目录
    Java 集合系列目录(Category)
    ls参数
    在PATH路径中添加新的路径
    目录相关的操作
    chmod
    属性类型
    ls -al
  • 原文地址:https://www.cnblogs.com/luoguoxing/p/14855821.html
Copyright © 2011-2022 走看看