I'm trying to extract an image URl using python/lxml and the xpath()
command, but am having trouble isolating the url itself.
Here is the HTML surrounding the img
src
that I want:
<div data-index="0" data-za-action="Photo Lightbox - Open" data-za-
category="Homes" class="img-wrapper za-track-event zsg-lightbox-show"
data-target-id="hdp-photo-lightbox" data-za-label="position: 0, total:
18, id: 10660534745" id="yui_3_18_1_2_1519884476676_1986"><img
src="https://photos.zillowstatic.com/p_h/IS2fordnekys6d1000000000.jpg"
onload="if (typeof ClientProfiler !== 'undefined') {
ClientProfiler.profile('HDPFirstPhotoLoaded') }" id="X1-
IAgz3dcnekys6d1000000000_ptw8e" class="hip-photo"></div>
Specifically, I want to isolate the https://photos.zillowstatic.com/p_h/IS2fordnekys6d1000000000.jpg
url.
I've tried a few approaches without success, including variations on the following:
xpath(".//img[@class='hip-photo']/@src")
xpath(".//img[@class='hip-photo']//text()")