【发布时间】:2016-10-26 03:31:28
【问题描述】:
我正在尝试抓取一个新闻网站,我需要更改一个参数。我用下一个代码替换它:
while i < len(links):
conn = urllib.urlopen(links[i])
html = conn.read()
soup = BeautifulSoup(html)
t = html.replace('class="row bigbox container mi-df-local locked-single"', 'class="row bigbox container mi-df-local single-local"')
n = str(t.find("div", attrs={'class':'entry cuerpo-noticias'}))
print(p)
问题是“t”类型是字符串,带有属性的查找只适用于类型<class 'BeautifulSoup.BeautifulSoup'>。你知道如何将“t”转换为那种类型吗?
【问题讨论】:
标签: python beautifulsoup web-crawler html-parsing