why can not parse the web in almost same xpath expression?

python mailtomanage at 163.com
Thu Feb 21 09:09:19 EST 2013


    import urllib
    import lxml.html
    down='http://v.163.com/special/visualizingdata/'
    file=urllib.urlopen(down).read()
    root=lxml.html.document_fromstring(file)
    urllist=root.xpath('//div[@class="down s-fc3 f-fl"]//a') 
    for url in urllist:
         print url.get("href")
  
i get the output ,  
http://mov.bn.netease.com/movieMP4/2012/12/A/7/S8H1TH9A7.mp4  
http://mov.bn.netease.com/movieMP4/2012/12/D/9/S8H1ULCD9.mp4  
http://mov.bn.netease.com/movieMP4/2012/12/4/P/S8H1UUH4P.mp4  
http://mov.bn.netease.com/movieMP4/2012/12/B/V/S8H1V8RBV.mp4  
http://mov.bn.netease.com/movieMP4/2012/12/6/E/S8H1VIF6E.mp4  
http://mov.bn.netease.com/movieMP4/2012/12/B/G/S8H1VQ2BG.mp4  
  
when i change   


    xpath('//div[@class="down s-fc3 f-fl"]//a')
   
into   


    xpath('//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')  


why i can't get nothing? 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130221/71afe2b3/attachment.html>


More information about the Python-list mailing list