我想抓取一个页面的文件:
<body class="body_class" style="background:#444;">
<div class="data" id="id">
<div id="images" style="cursor: auto;">
<img id="page-1" src="image1.jpg" data-index="1" style="" data-bd-imgshare binded="1">
<p class="img_info">(1/14)</p>
</div>
</div>
</body>
我想获取数据image1.jpg。
我试过代码
from lxml import html
import requests
page = requests.get(r'http://example.com')
tree = html.fromstring(page.content)
a = tree.xpath('//div[@id="images"]/src/text()')
它失败。如何获取数据?
谢谢。