def scrape_url(url, outpath):
"""
Requires webkit2png to be on the path
"""
subprocess.call(["webkit2png", "-o", outpath, "-g", "1000", "1260",
"-t", "30", url])
def scrape_list_urls(list_url_out_name, outdir):
"""
list_url_out_name is a list of tuples: (url, name)
where name.png will be the image's name
"""
count = 0
for url, name in list_url_out_name:
print count
count += 1
outpath = outdir + name + '.png'
scrape_url(url, outpath)
可能是这样的(未经测试):
这是不知羞耻地从source code of webkit2png.py上撕下来的。
我用
subprocess
调用webkit2png
(它是通过python-webkit2png
安装的), 它工作得很好。在这里,我使用了一个参数来传递.txt的位置,它包含一个站点列表(以换行分隔),以及输出PNG文件位置的第二个参数。
https://gist.github.com/deadstar1/e8d30102afbaefec531d6708f761e104 感谢@paljenczy
相关问题 更多 >
编程相关推荐