0

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

Dave2e
  • 22,192
  • 18
  • 42
  • 50
AbdulAziz
  • 1
  • 4

1 Answers1

0

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)
danidee
  • 9,298
  • 2
  • 35
  • 55
  • that actually worked thanks for taking the time to check the website :D now i only need to show both the link and title for that link – AbdulAziz Sep 09 '16 at 03:27
  • You could look through `link` again. i'm glad you got it to work....don't forget to accept my answer if it worked for you :) – danidee Sep 09 '16 at 03:35
  • can I do, href = link.get('a href') print(href) ? – AbdulAziz Sep 09 '16 at 03:45
  • no you can add an extra loop...something like, `for title in link: print(title)`...title will give you the individual divs – danidee Sep 09 '16 at 03:48