1
我想从这个网页刮数据标签:http://www.kitco.com/texten/texten.html如何凑网页缺乏使用BeautifulSoup
这里是我使用的代码:
import requests
from bs4 import BeautifulSoup
url = "http://www.kitco.com/texten/texten.html"
r = requests.get(url)
# Doing this to force UFT-8 encoding. Not sure if this is needed...
r.encoding = "UTF-8"
soup = BeautifulSoup(r.content)
tag = soup.find_all("London Fix")
print tag
正如您看到的,而查看该页面的来源,术语“伦敦修复”是不是在任何标签 - 我不知道这是否是cdata或什么...
任何想法如何解析这些表?
如果您正在使用的是r.content,则确实不需要设置r.encoding。顺便说一句,这是完全正确的。 – 2014-08-29 17:20:21
我认为这太宽泛了,但我也可以证明'你不清楚你问的是什么',因为你没有指定你期望的输出。 – 2014-08-29 17:21:45
我建议你开始阅读[BeautifulSoup文档](http://www.crummy.com/software/BeautifulSoup/bs4/doc/)更仔细一点,看看'soup.find_all()'*做*,作为好。 – 2014-08-29 17:22:26