Skip to content

Instantly share code, notes, and snippets.

@upbit
Created March 23, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save upbit/f04acd8e538028a7d2f94f815666923d to your computer and use it in GitHub Desktop.
Save upbit/f04acd8e538028a7d2f94f815666923d to your computer and use it in GitHub Desktop.
游戏和解说名提取
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from bs4 import BeautifulSoup
def fetch_17173_game_list():
url = 'http://www.17173.com'
r = requests.get(url)
r.encoding = 'utf-8'
soup = BeautifulSoup(r.text, 'html.parser')
return soup.findAll('div', {'class': 'game-hot'})[0]
def main():
div_hot = fetch_17173_game_list()
for ul in div_hot.findAll('ul', {'class': 'links-game'}):
title = ul.findAll('h3', {'class': 'tit'})[0].text
games = [ span.text for span in ul.findAll('span') ]
print title, ','.join(games)
if __name__ == '__main__':
main()
最热 守望先锋,穿越火线,炉石传说,梦幻西游,新天龙,魔兽世界,地下城与勇士,剑网3,英雄联盟,大青云
最新 装甲战争,失落的方舟,战意,虎豹骑,修魔世界,天衍录,挂机爆神装回收RMB,灵山奇缘,长城OL,MU:传奇,炽焰帝国2
手游 仙境传说RO,皇室战争,不思议迷宫,部落冲突,王者荣耀,崩坏3,梦幻西游,我的世界,梦幻诛仙,大唐无双手游,穿越火线,阴阳师,镇魔曲手游,赤月传奇,倩女幽魂,问道手游,光明大陆,大话西游,街头篮球,刀剑乱舞,剑与家园,坦克世界闪击战,传奇世界手游,饥荒,龙之谷手游,火焰纹章:英雄,天堂2:誓言,街篮,HIT,FateGO
页游 奇迹MU,剑灵洪门崛起,暗黑II萌神,钢铁苍穹,百年战记,热血修仙之传奇,勇者斗恶龙,枪战英雄,蓝月传奇装备回收,一骑当千
: 注意需先标注别名
@upbit
Copy link
Author

upbit commented Mar 23, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment