Python: What's wrong with my xpath expression? -
Python: What's wrong with my xpath expression? -
i have this:
<div class="down_butt_pad1" style="" id="downloadlink"><a href="http://www.link.com" class="down_butt1" onclick="javascript:window.open('http://s.spam.com','popunder','width=800,height=800,scrollbars=yes,status=no,resizable=yes, toolbar=no'); window.focus();"></a></div>
i'm trying xpath("//div[@id == 'downloadlink']")
error ("lxml.etree.xpathevalerror: invalid expression").
what's wrong doing , how can search div id has downloadlink instead then?
you have utilize single =
in xpath. you're looking is
"//div[@id='downloadlink']"
however, there nil interesting div. why stop there? perhaps want extract url:
"//div[@id='downloadlink']/a/@href"
i recommend using deep dive extract want, rather stopping @ container element, invoking xpath engine 1 time again or switching tree-style navigation.
python xpath
Comments
Post a Comment