Python 爬天天基金,简单实例xpath,Requests+lxml框架

Python 爬天天基金,简单实例xpath,Requests+lxml框架
tiantian.py

import urllib.request

from lxml import etree

url = "http://fund.eastmoney.com/002624.html"
response = urllib.request.urlopen(url).read()
selector = etree.HTML(response)
xpathselector = '//*[@id="body"]/div[12]/div/div/div[2]/div[1]/div[1]/dl[2]/dd[1]/span[1]'
node = selector.xpath(xpathselector)
print(node[0].text)