2017-07-11 72 views
1

多屏预期,但我只得到了第一个。 这里是我的代码,我试图Python中,多屏幕快照使用PhantomJS

from selenium import webdriver 
    client_urls = 
    ['https://www.facebook.com/','http://www.https://stackoverflow.com'] 
    for client_url in client_urls: 
     driver = webdriver.PhantomJS('C:\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe') 
     driver.get(client_url) 
     print(client_url) 
     screen = client_urls 
     driver.get_screenshot_as_file('C:\\Users\\xyz\\output\\b.png') 
     driver.quit()''' 

回答

0

我注意到的第一件事是在地址计算器是错误的。

尝试这样:

driver = webdriver.PhantomJS('C:\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe') 
for client_url in client_urls: 
    driver.get(client_url) 
    driver.get_screenshot_as_file('C:\\Users\\xyz\\output\\'+client_url+'.png') 
driver.quit() 

我还要考虑PIL,如果你想将图像加入到一个单一的形象。

+0

我会尝试PIL,但该URL可能是一个错字,错误对不起 –