Advertisement
Guest User

Untitled

a guest
May 11th, 2019
536
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. >>> import requests
  2. >>> from bs4 import BeautifulSoup
  3. >>> bahammut_ranking_html=requests.get("https://www.gamer.com.tw/")
  4. >>> soup=BeautifulSoup(bahammut_ranking_html.text,"html.parser")
  5. >>> soup.find(id="gamechart-hot").findAll(class_="hotgame")
  6. [<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>]
  7. >>> soup.find(id="gamechart-hot").findAll(class_="hotgame").findAll(class_="game")
  8. Traceback (most recent call last):
  9. File "<pyshell#5>", line 1, in <module>
  10. soup.find(id="gamechart-hot").findAll(class_="hotgame").findAll(class_="game")
  11. File "C:\Users\user\AppData\Local\Programs\Python\Python37\lib\site-packages\bs4\element.py", line 1620, in __getattr__
  12. "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
  13. 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()?
  14. >>>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement