来自这样的html/rss片段
[...]<div class="..." style="..."></div><p><a href="..."
<img alt="" heightt="" src="http://link.to/image"
width="" /></a><span style="">[...]
Run Code Online (Sandbox Code Playgroud)
我想获取图像src链接"http://link.to/image.jpg".我怎么能在python中这样做?谢谢.
lxml 是工作的工具.
从网页上抓取所有图像就像这样简单:
import lxml.html
tree = lxml.html.parse("http://example.com")
images = tree.xpath("//img/@src")
print images
Run Code Online (Sandbox Code Playgroud)
赠送:
['/_img/iana-logo-pageheader.png', '/_img/icann-logo-micro.png']
如果它是RSS提要,您需要解析它lxml.etree.
| 归档时间: |
|
| 查看次数: |
5477 次 |
| 最近记录: |