Python中文
首页
教程
问答
标签
搜索
登录
注册
在python中使用beauthoulsoup的输出
回答此问题可获得
20
贡献值,回答如果被采纳可获得
50
分。
<p>嘿,大家好,我正在使用beautifulsoup(在与scrapy挣扎了两天之后)来收集星际争霸2的联盟数据,但是我遇到了一个问题。在</p> <p>我有一个表格,结果是我想要所有标签的字符串内容,我这样做:</p> <pre><code>from BeautifulSoup import * from urllib import urlopen def parseWithSoup(url): print "Reading:" , url html = urlopen(url).read().lower() bs = BeautifulSoup(html) table = bs.find(lambda tag: tag.name=='table' and tag.has_key('id') and tag['id']=="tblt_table") rows = table.findAll(lambda tag: tag.name=='tr') rows.pop(0) #first row is header for row in rows: tags = row.findAll(lambda tag: tag.name=='a') content = [] for tagcontent in tags: content.<a href="https://www.cnpython.com/list/append" class="inner-link">append</a>(tagcontent.string) print content if __name__ == '__main__': content = "http://www.teamliquid.net/tlpd/sc2-international/games#tblt-5018-1-1-DESC" metSoup = parseWithSoup(content) </code></pre> <p>但输出如下:</p> ^{pr2}$ <p>我的问题是:u'来自哪里(它来自unicode吗?)我怎样才能去掉这个?我只需要你身上的琴弦。。。在</p>
0 条评论
分类:
Python问答
请先
登录
后评论
默认排序
时间排序
1 个回答
匿名
1天前
擅长:python、mysql、java
<p>您看到的是Python unicode字符串。在</p> <p>查看Python文档</p> <p><a href="http://docs.python.org/howto/unicode.html" rel="nofollow">http://docs.python.org/howto/unicode.html</a></p> <p>为了正确处理unicode字符串。在</p>
请先
登录
后评论
针对此问题:
更多的回答
关注
89
关注
收藏
1
收藏,
216
浏览
网友 提问于 2天前
相关Python问题
得到媒体:缩略图url从rss源
4 回答
得到对数正态随机数给定log10均值和log10标准差
1 回答
得到工作,波斯特不
1 回答
得到左半积和右半积的绝对差最小的元素
9 回答
得到幻数错误?
7 回答
得到异常错误“线程中的异常-1(最有可能在解释器关闭期间引发)”,它使用Parami
6 回答
得到循环
5 回答
得到德语的语法变化
4 回答
得到我认为是好的结果,但还不够
5 回答
得到截断svd.transform()返回float16而不是float64
9 回答
得到所有不相交的集合的并集
10 回答
得到所有函数求值组合的矩阵
6 回答
得到扭曲延迟取消错误当使用刮痧时
6 回答
得到控制台.log使用Selenium python从Chrome输出一次,然后调用第二次为空
3 回答
得到操作系统环境通过NSSM运行Python
5 回答
得到数学方程中的表达式
6 回答
得到数据库结构属性
9 回答
得到整数的后三位
10 回答
得到整数的第n位精度
4 回答
得到最低落的reddit评论
8 回答