2024-06-28 11:03:17 发布
网友
我正在抓取这个网站 http://www.propertyfinder.ae/en/buy/villa-for-sale-dubai-jumeirah-park-1849328.html?img/0
我想得到这个标记中的所有图像src div[@id='propertyPhoto']
div[@id='propertyPhoto']
我试过这个xpath
.//div[@id='propertyPhoto']//img/@src
我做了一个循环来提取src,但是我只得到了第一个图像src
请帮忙
只有主图像在div#propertyPhoto中。其他的在li#propertyPhotoMini0,li#propertyPhotoMini1。。。在
div#propertyPhoto
li#propertyPhotoMini0
li#propertyPhotoMini1
所以XPath应该稍加修改以匹配两者。id它们的属性都以propertyPhoto开头;可以使用以下XPath:
id
propertyPhoto
.//*[starts-with(@id, 'propertyPhoto')]//img/@src
示例:
输出:
http://c1369023.r23.cf3.rackcdn.com/1849328-1-wide.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-1-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-2-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-3-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-4-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-5-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-6-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-7-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-8-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-9-mini.jpg http://c1369023.r23.cf3.rackcdn.com/1849328-10-mini.jpg
只有主图像在
div#propertyPhoto
中。其他的在li#propertyPhotoMini0
,li#propertyPhotoMini1
。。。在所以XPath应该稍加修改以匹配两者。
id
它们的属性都以propertyPhoto
开头;可以使用以下XPath:示例:
^{pr2}$输出:
相关问题 更多 >
编程相关推荐