2016-06-22 7 views
0

私はLinuxでhtmlソースを取得するためにpython webdriverを使用しようとしています。Python OSError:[Errno 2]このようなファイルはありません

しかし、私はエラーの下になった:

python daiwa.py 'http://asp.hotel-story.ne.jp/ver3d/planlist.asp?herehcod1=DWHQ0&sAreacode=00151&hidmode=select&mode=seek&hidSELECTARRYMD=2016/06/22&hidSELECTadult=1'Traceback (most recent call last): 
File "/var/www/daiwa/lib/otas/daiwa.py", line 9, in <module> 
xephyr=Display(visible=1, size=(320, 240)).start() 
File "/usr/local/lib/python2.7/site-packages/pyvirtualdisplay/display.py", line 33, in __init__self._obj = self.display_class(
File "/usr/local/lib/python2.7/site-packages/pyvirtualdisplay/display.py", line 51, in display_classcls.check_installed() 
File "/usr/local/lib/python2.7/site-packages/pyvirtualdisplay/xephyr.py", line 30, in check_installed ubuntu_package=PACKAGE).check_installed() 
File "/usr/local/lib/python2.7/site-packages/easyprocess/__init__.py", line 180, in check_installed 
raise EasyProcessCheckInstalledError(self) 
easyprocess.EasyProcessCheckInstalledError: cmd=['Xephyr', '-help'] 
OSError=[Errno 2] No such file or directory 
Program install error! 

誰かが私を助けることができますか?

バージョン:python - > 2.7.9 これは私のコードです。

xephyr=Display(visible=0, size=(320, 240)).start() # visible=0 

#-*- coding: utf-8 -*- 
from pyvirtualdisplay import Display 
from selenium import webdriver 

xephyr=Display(visible=1, size=(320, 240)).start() 

path_to_chromedriver = "/usr/local/bin/chromedriver" 

templete = webdriver.Chrome("/usr/local/bin/chromedriver") 
templete.get("https://asp.hotel-story.ne.jp/ver3d/planlist.asp?hcod1=DWHQ0&hcod2=001&hidmode=select&mode=seek&hidSELECTARRYMD=2016/6/25&hidSELECTHAKSU=1&room=1&hidSELECTadult=1&hidSELECTchilda=0&hidSELECTchildb=0&hidSELECTchildc=0&hidSELECTchildd=0&hidSELECTminPrice=0&hidSELECTmaxPrice=9999999&Dispunit=&chkymd=0&chkpsn=0&sAreacode=00101") 

templete.find_element_by_xpath("//select[@id='seekCount']/option[@value='9999']").click() 

html_source = templete.page_source 

if isinstance(html_source, unicode): 
    html_source = html_source.encode('UTF-8') 

print html_source 

templete.close() 
+0

あなたが '' xvfb'須藤はapt-getをインストールxvfb'をインストールしましたか? – ravigadila

+0

@RaviKumarはい、yumでxvfbをインストールxvfb – jonggu

+0

tyr 'pip install xvfbwrapper' – ravigadila

答えて

0
あなたのコードの変更ラインで

xephyr=Display(visible=1, size=(320, 240)).start() 

バックエンドXephyrであれば:

display = Display(visible=1, size=(320, 240)).start() # visible=1 

バックエンドの場合Xvfbのは:

display = Display(visible=0, size=(320, 240)).start() # visible=0 
+0

Thankx !!しかし、私はそのような別のエラーメッセージを持っています selenium.common.exceptions.WebDriverException:メッセージ:Service/usr/local/bin/chromedriverが突然終了しました。ステータスコード:1 – jonggu

+0

上記のコードはFirefoxのwebdriverで動作します。この[リンク](http://stackoverflow.com/questions/8255929/running-webdriver-chrome-with-selenium/24364290#24364290)は、chrome webdriverのWebDriverExceptionに役立ちます – ravigadila

関連する問題