我试图从一个表中获取数据-即(http://stats.nba.com/leagueTeamGeneral.html?pageNo=1&rowsPerPage=30)。我很难使用正确的命令。试过各种参数,都没用。最好是以格式返回数据,
例子:
亚特兰大老鹰队,32、48.8、18、14、563等
我可以得到格式化的数据没有问题,只是得到所需的数据是什么让我悲伤。在
import urllib2
from bs4 import BeautifulSoup
page = 'http://stats.nba.com/leagueTeamGeneral.html?pageNo=1&rowsPerPage=30'
page = urllib2.urlopen(page)
soup = BeautifulSoup(page)
for dS in soup.find_all(???):
print(dS.get(???))
谢谢你的建议,效果不错。我最后用的是
使用firefox firebug这样的工具来跟踪您需要的html调用,查看您在firebug的“net”选项卡中共享的链接,就会发现您所追求的数据是在对
http://www.nba.com/cmsinclude/desktopWrapperHeader_jsonp.html
的后续请求调用中获得的 它实际上包含json数据,不确定beauthoulsoup在这里是否方便,请尝试使用pythonjson
加载它相关问题 更多 >
编程相关推荐