http://en.wikipedia.org/wiki/List_of_cities_in_China
I want to extract all city names as shown below:
I use the following code (for only extract one field), where xpath is copy from chrome
from lxml import html
import requests
page = requests.get('http://en.wikipedia.org/wiki/List_of_cities_in_China')
tree = html.fromstring(page.text)
huabeiTree=tree.xpath('//*[@id="mw-content-text"]/table[3]/tbody/tr[1]/td[1]/a/text()')
print huabeiTree
Nothing appears.
My ultimate goal is to extract all cities in the list, may I know how to achieve this?