xpath function / metadata agent

Hi,



Trying to develop a metadata agent for retrieving subtitles from Addict7ed.com and I don’t know a thing about Python and have been struggling to strip a page down of all unwanted elements using xpath



<br />
elem = HTML.ElementFromURL(searchURL)<br />
alltext = elem.xpath(".//*[@id='container95m']/table/tbody/tr[2]/td[2]/table/tbody/tr[*]/td[*]")<br />
for item in alltext:<br />
 Log("text = %s" % item)



Running this xpath against a query checker just scraps everything that I want.
Still, it seems like "alltext" list is empty. Sometimes, I do get some results by playing around the query but I cannot get the HTML code behind it to parse it and do whatever I want with it because it would simply displays "Element xxx at xxxxx"

Some help would be greatly appreciated! Thanks

Hi,



Can you paste the full code, with the python import statements etc and the URL populated?

You can test your xpath queries in chrome. Simply go to the page you are parsing, open console, and type



$x(’.//[@id=“container95m”]/table/tbody/tr[2]/td[2]/table/tbody/tr[]/td’);



this will run the given xpath query and return the results. priceless for quick debugging of your xpath syntax.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.