1
我也跟着上stackoverflow
發現建議代碼調用,但我得到一個錯誤:錯誤綁定get()方法必須使用的webdriver phantomJs
unbound method get() must be called with WebDriver instance as first argument (got str instance instead)
我的代碼是:
>>> from selenium import webdriver
>>> import time
>>> from bs4 import *
>>> sns_sources = 'www.abc.com'
>>> driver = webdriver.PhantomJS
>>> driver.get(sns_sources)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unbound method get() must be called with WebDriver instance as first argument (got str instance instead)
你不是實例'PhantomJS',所以'driver'只是一個「webdriver.PhantomjS」類的其他名稱。您不能直接在類上調用'.get()'而不通過實例作爲第一個參數。 – kindall