Issues a longer xpath expression

python mailtomanage at
Fri Feb 22 02:24:09 CET 2013

I am having issues with the urllib and lxml.html modules.

Here is my original code:

import urllib  
import lxml.html  
xpath_str="//div[@class='down s-fc3 f-fl']/a"  
urllist=root.xpath(xpath_str)for url in urllist:print url.get("href")

When run, it returns this output:  

But, when I change the line

xpath_str='//div[@class="down s-fc3 f-fl"]//a'


xpath_str='//div[@class="col f-cb"]//div[@class="down s-fc3 f-fl"]//a'

that is to say,

urllist=root.xpath('//div[@class="col f-cb"]//div[@class="down s-fc3 f-fl"]//a')

I do not receive any output. What is the flaw in this code?
it is so strange that the shorter one can work,the longer one can not,they have the same xpath structure!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list