我有这个
HTML代码:
aaa | bbb | ccc | ddd |
eee | fff | ggg | hhh |
我使用这个Python代码来提取所有< td class =“test”>使用lxml模块.
import urllib2
import lxml.html
code = urllib.urlopen("http://www.example.com/page.html").read()
html = lxml.html.fromstring(code)
result = html.xpath('//td[@class="test"][position() = 1 or position() = 4]')
它很好用!结果是:
aaa ddd eee hhh(所以每个< tr>的第一和第四列)
现在,我必须提取:
aaa (the title of the link)
ddd (text between tag)
eee (the title of the link)
hhh (text between tag)
我怎样才能提取这些值?
(问题是我必须删除< b>标记并在第一列上获取锚点的标题并删除第四列上的< small>标记)
谢谢!