擅长:python、mysql、java
<p>我用<code>subprocess</code>调用<code>webkit2png</code>(它是通过<code>python-webkit2png</code>安装的),
它工作得很好。</p>
<pre><code>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)
</code></pre>