node.js - Using PhantomJs with Python/Selenium -


i attempting phantomjs in order run webscrapes selenium , python without needing open new window when scrape loops next page.

i consulted post initially: is there way use phantomjs in python?

however had modify path node.exe in code below:

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 

i error:

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 

i have no idea doing because use chromedriver, if me awesome.

my phantomjs file wasn't in script folder. put in folder under python27.


Comments

Popular posts from this blog

account - Script error login visual studio DefaultLogin_PCore.js -

xcode - CocoaPod Storyboard error: -