Search code examples
pythonvisual-studiopython-3.4ptvs

Beautiful soup isn't showing the links


I am trying to scrap an anime website for the anime episodes links and titles, but the output is showing nothing or shows [] only.
This is the code am using:

import requests
from bs4 import BeautifulSoup

r = requests.get('http://animeonline.vip/info/phi-brain-kami-puzzle-3')
soup = BeautifulSoup(r.content, "html.parser")
for link in soup.find_all('a',{'class':"list_episode"}):    
print(link)

Anyway, I suppose this will only list down the links inside that class. How can I show title beside each link?

I have no idea what I am doing wrong.

Thanks


Solution

  • The div has the class attribute, not the anchor tags, you were almost there

    for link in soup.find_all('div', {'class': 'list_episode'}):
         print(link)