我正在尝试制作一个web scraper,它将解析出版物的web页面并提取作者。网页的框架结构如下:
####I want whatever is located here ### |
到目前为止,我一直在尝试使用BeautifulSoup和lxml来完成这项任务,但我不确定如何处理这两个div标记和td标记,因为它们具有属性。除此之外,我不确定是否应该更多地依赖于BeautifulSoup或lxml或两者的结合。我该怎么办?
目前,我的代码如下所示:import re
import urllib2,sys
import lxml
from lxml import etree
from lxml.html.soupparser import fromstring
from lxml.etree import tostring
from lxml.cssselect import CSSSelector
from BeautifulSoup import BeautifulSoup, NavigableString
address='http://www.example.com/'
html = urllib2.urlopen(address).read()
soup = BeautifulSoup(html)
html=soup.prettify()
html=html.replace(' ', ' ')
html=html.replace('í','í')
root=fromstring(html)
我意识到很多导入语句可能是多余的,但我只是复制了更多源文件中当前的所有内容。
编辑:我想我没有说得很清楚,但我有多个标签在页面上,我想刮。