鍍金池/ 問答/Linux  HTML/ 利用phantomjs對網(wǎng)頁批量截圖結(jié)果都是空白圖片?

利用phantomjs對網(wǎng)頁批量截圖結(jié)果都是空白圖片?

from selenium import webdriver
import os
driver= webdriver.PhantomJS(executable_path=r'/usr/local/bin/phantomjs')
inputfile=raw_input('please input file adress')
for file in os.listdir(inputfile):
       s=('file://'+str(inputfile)+'/'+str(file))
       print s
       driver.set_page_load_timeout(4)
       driver.get(s)
       driver.save_screenshot('/Users/libai/codelearning/html2pic/%s.png' %file)
driver.close()

如圖。沒找到問題出在哪?
圖片描述

回答
編輯回答
近義詞

協(xié)議頭應(yīng)該是file:///,改下試試
file_url

Note that when omitting host, the slash is not omitted (while "file:///foo.txt" is valid, "file://foo.txt" is not, although some interpreters manage to handle the latter).

不行的話開個本地服務(wù)器,用localhost:port的方式打開看看

2018年1月9日 13:00