2014-07-04 7 views
9

मैंने पाइथन डब्ल्यू/सेलेनियम और फैंटॉमजेएस में एक सरल वेबक्रैपिंग स्क्रिप्ट सेट की है। मुझे स्क्रैप करने के लिए कुल 200 यूआरएल मिल गए हैं। स्क्रिप्ट पहले 20-30 यूआरएल के बाद पहले ठीक हो जाती है (यह असफल होने पर यादृच्छिक लगता है और यह किसी विशेष यूआरएल से संबंधित नहीं है) मुझे पाइथन में निम्न त्रुटि मिलती है:सेलेनियम GhostDriver से कनेक्ट नहीं हो सकता है (लेकिन केवल कभी-कभी)

selenium.common.exceptions.WebDriverException: Message: 'Can not connect to GhostDriver' 

और मेरे ghostdriver.log:

PhantomJS is launching GhostDriver... 
[ERROR - 2014-07-04T17:27:37.519Z] GhostDriver - main.fail - {"message":"Could not start Ghost Driver","line":82,"sourceId":140692115795456,"sourceURL":":/ghostdriver/main.js","stack":"Error: Could not start Ghost Driver\n at :/ghostdriver/main.js:82","stackArray":[{"sourceURL":":/ghostdriver/main.js","line":82}]} 

मैं खोज की है और इतने पर सवालों के अधिकांश है कि वे एक भी यूआरएल नहीं चल सकता होने लगते हैं। एकमात्र अन्य प्रश्न जो मैंने पाया है, जहां स्क्रिप्ट के बीच में त्रुटि होती है this one है और इसका जवाब फ़ैंटोमज को नवीनतम संस्करण में अपग्रेड करना है, जो मैंने किया है। दूसरा जवाब बस उस यूआरएल को फिर से कोशिश करने के लिए कहता है और यह एक अच्छा समाधान नहीं लगता है क्योंकि यूआरएल फिर से असफल हो सकता है।

मैं लिनक्स टकसाल 17 पर phantomjs संस्करण 1.9.7 और सेलेनियम संस्करण 2.42.1 चला रहा हूँ अजगर 2.7.6

for url in ['example.com/1/', 'example.com/2/', 'example.com/3/', .. , ..]: 
    user_agent = 'Chrome' 
    dcap = dict(DesiredCapabilities.PHANTOMJS) 
    dcap['phantomjs.page.settings.userAgent'] = user_agent 
    driver = webdriver.PhantomJS(executable_path='/usr/bin/phantomjs', desired_capabilities=dcap) 
    driver.get(url) 
+1

'row.url' क्या है? –

+0

@ पैड्राइक कनिंघम: टाइपो। फिक्स्ड। –

+1

आपने phantomjs कैसे इंस्टॉल किया? –

उत्तर

8

पर मुझे लगता है मैं स्रोत से phantomjs स्थापित यह ठीक करने के लिए एक ही समस्या थी।

For Linux (Debian): 
sudo apt-get update 
sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev libxft-dev 
git clone git://github.com/ariya/phantomjs.git 
cd phantomjs 
git checkout 1.9 
./build.sh 

For Mac os: 
git clone git://github.com/ariya/phantomjs.git 
cd phantomjs 
git checkout 1.9 
./build.sh 

अन्य प्रणालियों के लिए नीचे दिए गए लिंक http://phantomjs.org/build.html

Optional : 
cd bin 
chmod +x phantomjs 
cp phantomjs /usr/bin/ 

मैं इसे समझ से बाहर है क्योंकि जब मैं अपने ghostdriver.log फ़ाइल को पढ़ने यह कहा की जाँच करें।

[ERROR - 2014-09-04T19:33:30.842Z] GhostDriver - main.fail - {"message":"Could not start Ghost Driver","line":82,"sourceId":140145669488128,"sourceURL":":/ghostdriver/main.js","stack":"Error: Could not start Ghost Driver\n at :/ghostdriver/main.js:82","stackArray":[{"sourceURL":":/ghostdriver/main.js","line":82}]} 

मुझे यकीन है कि वहाँ कुछ गुम फ़ाइलें जो, यह कुछ बढ़त के मामलों के लिए उपयोग करना चाहिए होना चाहिए था। तो मैंने अब स्रोत और उसके कामकाजी जुर्माना से निर्माण करने का फैसला किया।

+1

ओएसएक्स के लिए बिल्डिंग प्रेत गधे में दर्द है। यह क्यूटी libs के लिए पूछता है। – Volatil3

संबंधित मुद्दे