I've been tearing my hair out playing with variations on this:
'//*[@id="mw-content-text"]/div[2]/table/tbody/tr/td/div/ul/li/a'
as an XPath to get all of the school district urls from this wiki page: http://en.wikipedia.org/wiki/List_of_school_districts_in_Arkansas . What's the correct XPath?
Thanks in advance!
Code snippet:
print 3.1, tree.xpath('//*[@id="mw-content-text"]/div[2]')
print 3.2, tree.xpath('//*[@id="mw-content-text"]/div[2]/table')
print 3.3, tree.xpath('//*[@id="mw-content-text"]/div[2]/table/tbody')
print 3.4, tree.xpath('//*[@id="mw-content-text"]/div[2]/table/tbody')
print 3.5, tree.xpath('//*[@id="mw-content-text"]/div[2]/table/tbody/tr/td/div/ul/li/a/text()')
for row in tree.xpath('//*[@id="mw-content-text"]/div[2]/table/tbody/tr/td/div/ul/li/a/text()'):
print row
district_urls.append('http://en.wikipedia.org'+row.get('href'))
As a reference:
3.1 [<Element div at 0x1109f7f00>]
3.2 [<Element table at 0x1109f7f00>]
3.3 []
3.4 []
3.5 []