BeautifulSoup实体引用应该怎样做,beautifulsoup实体,template = c


template = codecs.open('template.html', 'r' , 'utf-8')template = template.read()template = bs(template)resp = requests.get('http://blog.jobbole.com/61171/')html = resp.text.encode('utf-8')html = bs(html)t = html.title.stringtemplate.title.string = ttemplate.div.string = str(html.select('div.entry')[0])out = codecs.open(''.join(['result/', t, '.html']), 'w' , 'utf-8')# out.write(str(template))# print(template)print(str(html.select('div.entry')[0]))

如果直接输出 str(html.select('div.entry')[0]) 时尖括号不会转义,
但输出 template 就会转义。

现在我想让template就保持原样(既不escape也不unescape)应该怎样做呢?谢谢大家了。

编橙之家文章,

评论关闭