Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >>> import requests
- >>> from bs4 import BeautifulSoup
- >>> bahammut_ranking_html=requests.get("https://www.gamer.com.tw/")
- >>> soup=BeautifulSoup(bahammut_ranking_html.text,"html.parser")
- >>> soup.find(id="gamechart-hot").findAll(class_="hotgame")
- [<a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=59910"><p class="game">神魔之塔</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=79477"><p class="game">Pokemon GO</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=83801"><p class="game">Garena 傳說對決</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=103173"><p class="game">Garena 極速領域</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=71788"><p class="game">Fate/Grand Order</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=66219"><p class="game">怪物彈珠</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=99705"><p class="game">荒野亂鬥</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=84777"><p class="game">超異域公主連結☆Re:Dive</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=65483"><p class="game">爐石戰記</p></a>, <a class="hotgame" data-gtmgamer="手遊榜Android" href="//acg.gamer.com.tw/acgDetail.php?s=81303"><p class="game">部落衝突:皇室戰爭</p></a>]
- >>> soup.find(id="gamechart-hot").findAll(class_="hotgame").findAll(class_="game")
- Traceback (most recent call last):
- File "<pyshell#5>", line 1, in <module>
- soup.find(id="gamechart-hot").findAll(class_="hotgame").findAll(class_="game")
- File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\element.py", line 1620, in __getattr__
- "ResultSet object has no attribute '%s'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?" % key
- AttributeError: ResultSet object has no attribute 'findAll'. You're probably treating a list of items like a single item. Did you call find_all() when you meant to call find()?
- >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement