I'm wirting a script to scrape a webpage. My (debug) code is as follows (saved a local copy for faster testing):
doc = html.parse("C:\debug.html")
links = doc.xpath("//div[@class='download_item']")
print(links[0].xpath("//div[@class='download_title']"))
print(doc.xpath("//div[@class='download_title']")
For me unexpected, both printouts yield the same result (The one I would expect to search the whole document.) I verified that the "links" list contains the desired results. Now I want to search each element of links for the "download_title" class. There should be only one result per element. However it seems that the whole document is scanned. My question is why xpath does not search the element indicated (links[0]) but the whole document (doc) and how to search only the subelement links[0]