鱼C论坛

 找回密码
 立即注册
查看: 5048|回复: 5

python3 中get_cookie()要加什么参数吗

[复制链接]
发表于 2018-1-10 18:47:42 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
学习爬虫的时候,遇到的问题,调用selenium 中的 webdriver  的 get_cookie()
按照书上的程序却报一个TypeError: get_cookie() missing 1 required positional argument: 'name'错误 有大佬知道吗
代码如下
  1. from selenium import webdriver

  2. driver = webdriver.PhantomJS(executable_path="D:\python3\phantomjs-2.1.1-windows\\bin\phantomjs.exe")
  3. driver.get("http://pythonscraping.com")
  4. #driver.implicitly_wait(1)
  5. print(driver.get_cookie())
复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2018-1-12 17:23:30 | 显示全部楼层
http://blog.csdn.net/jackisthebestone/article/details/75605220
这里面讲了处理方法
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-1-10 21:04:41 | 显示全部楼层
  1. import os

  2. from selenium import webdriver

  3. chromedriver = "C:\Program Files (x86)\Mozilla Firefox\\firefox.exe"

  4. driver = webdriver.Firefox()

  5. driver.get('http://baidu.com')

  6. driver.quit()
复制代码
发现webdriver.Firefox()也用不了,报错:
  1. Traceback (most recent call last):
  2.   File "D:/c/爬虫/ex010.py", line 7, in <module>
  3.     driver = webdriver.Firefox()
  4.   File "D:\python3\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 144, in __init__
  5.     self.service.start()
  6.   File "D:\python3\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
  7.     os.path.basename(self.path), self.start_error_message)
  8. selenium.common.exceptions.WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
复制代码



小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 1 反对 0

使用道具 举报

发表于 2018-1-11 12:42:53 | 显示全部楼层
驱动路径
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2018-1-11 14:39:38 | 显示全部楼层

是想这样吗driver = webdriver.Firefox( "C:\Program Files (x86)\Mozilla Firefox\\firefox.exe")
还是报错。。。。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2018-1-11 16:41:26 | 显示全部楼层
mintaka 发表于 2018-1-11 14:39
是想这样吗driver = webdriver.Firefox( "C:\Program Files (x86)\Mozilla Firefox\\firefox.exe")
还是 ...

用火狐和谷歌做自动化好像还要下载插件,不过我当时都没用所以不记得了。
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2026-3-23 00:32

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表