您的位置:首页 > 其它

暴力拆解hupu球员信息

2015-07-11 00:44 211 查看

之前写了一个拉取nba球员的脚本,是针对hupu网站上的数据进行拉取。由于水平一般,代码写的简单粗暴

hupu球队\球员信息的链接

可以看到球员球队信息。爬出所有球队的链接

teamList = []
response = urllib2.urlopen("http://g.hupu.com/nba/players/")
html = response.read()
def getTeams():
Items = re.findall('<span class="team_name"><a href=".*?</a></span>',html,re.S)
for item in Items:
link = item.replace('<span class="team_name"><a href="','')
team = re.findall('">.*?</a></span>',link,re.S)[0]
link = 'http://g.hupu.com/'+link.replace(team,'')
team = team.replace('">','').replace('</a></span>','')
teamList.append(teamLink(team,link))


然后再爬出每个球员的详细页面

for team in teamList:
getPlayers(team)


并且获得数据,存入数据库



github链接https://github.com/Leon1Sun/TestPython
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  爬虫