2016-11-17 1 views
0

私は、スクレイプが次のページにループするときに新しいウィンドウを開く必要なく、SeleniumとPythonでWebスクラップを実行するためにPhantomJSを試しています。Python/SeleniumでPhantomJを使用する

Traceback (most recent call last): 
    File "C:/Users/dtrinh/PycharmProjects/TripAdvisorData/LinkPull-HK.py", line 23, in <module> 
    driver = webdriver.PhantomJS(r"C:\Program Files (x86)\nodejs\node.exe") 
    File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\phantomjs\webdriver.py", line 52, in __init__ 
self.service.start() 
    File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\common\service.py", line 86, in start 
self.assert_process_still_running() 
    File "C:\Python27\lib\site-packages\selenium-3.0.1-py2.7.egg\selenium\webdriver\common\service.py", line 99, in assert_process_still_running 
% (self.path, return_code) 
selenium.common.exceptions.WebDriverException: Message: Service C:\Program Files (x86)\nodejs\node.exe unexpectedly exited. Status code was: 9 
:私はこのエラーを取得する

for link in soup1.findAll('a', {'property_title'}): 
     #print 'https://www.tripadvisor.com/Restaurant_Review-g294217-' + link.get('href') 
     restaurant_url = 'https://www.tripadvisor.com/Restaurant_Review-g188590-' + link.get('href') 
     driver = webdriver.PhantomJS(r"C:\Program Files (x86)\nodejs\node.exe") 
     driver.get(restaurant_url) 
     neighborhood = driver.find_element_by_xpath(r'//*[@id="BODYCON"]/div[2]/div/div[2]/div[2]/div[1]/div[1]/div[2]/div[2]/div[2]/ul/li[3]') 
     restneighborhood = neighborhood.text 
     print restneighborhood 

:私は以下の私のコードでnode.exeしてもらうために、私のパスを変更する必要がありましたがIs there a way to use PhantomJS in Python?

:私が最初にこの記事を参考に

私はいつもChromeDriverを使用しているので、私は何をしているのか分かりませんが、誰かが私を助けてくれたらすごくいいです。

答えて

0

私のPhantomJSファイルはスクリプトフォルダにありませんでした。そのフォルダをPython27の下に置きます。

関連する問題