【发布时间】:2015-11-08 10:28:56
【问题描述】:
我能够使用我的技术成功获取 url,但重点是我需要稍微更改 url,如下所示:“http://www.example.com/static/p/no-name-0330-227404-1.jpg”。在 img 标签中我得到这个链接:“http://www.example.com/static/p/no-name-0330-227404-1-product.jpg”
HTML 代码:
<div class="swiper-wrapper"><img data-error-placeholder="PlaceholderPDP.jpg" class="swiper-lazy swiper-lazy-loaded" src="http://www.example.com/static/p/no-name-0330-227404-1-product.jpg"></div>
Python 代码:
imagesList = []
imagesList.append([re.findall(re.compile(u'http.*?\.jpg'), etree.tostring(imagesList).decode("utf-8")) for imagesList in productTree.xpath('//*[@class="swiper-wrapper"]/img')])
print (imagesList)
输出:
[['http://www.example.com/static/p/no-name-8143-225244-1-product.jpg']]
注意:我需要从 url 中删除“-product”,但我不知道为什么这个 url 在两个方括号内。
【问题讨论】: