Skip to content

Commit 7275c8a

Browse files
Merge pull request avinashkranjan#183 from pritamp17/anime_tracker
Anime tracker
2 parents 5d0f00c + b48c0b3 commit 7275c8a

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

Anime_Tracker/anime_tracker.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
2+
3+
try:
4+
import requests
5+
from bs4 import BeautifulSoup
6+
import urllib.parse as parse
7+
import re
8+
import argparse
9+
10+
except ImportError:
11+
print('Some modules are not installed! ')
12+
13+
# mainly bs4 lib is used for extracting html from web pages
14+
15+
def details(soup):
16+
17+
info = soup.find('div', {'class': 'pure-1 md-3-5'}) # selecting div with class pure...
18+
print("\nAbout the Anime : \n", "\t\t", info.find('p').getText(), "\n") # now extracting the text for p tag of the div
19+
20+
total_episodes = soup.find('div', {'class': 'pure-1 md-1-5'})
21+
print("\nTotal number of episodes :\t",
22+
re.sub("[^0-9]", "", total_episodes.find('span').getText())) # usimg regex for only selecting numbers
23+
24+
Active_years = soup.find('span', {'class': 'iconYear'})
25+
print("\n Years Active (From-To)\t:\t",
26+
Active_years.getText(), "-\n")
27+
28+
rating = soup.find('div', {'class': 'avgRating'})
29+
print("Rating : ", rating.find('span').getText())
30+
31+
tags = soup.find('div', {'class': 'tags'})
32+
# print("Tags : ", tags.find('ul').getText())
33+
34+
list = []
35+
for _ in range(4):
36+
list.append(tags.find('ul').getText())
37+
38+
print("\nTags : \n")
39+
print((list[0].replace("\n", " ")))
40+
41+
42+
def entry():
43+
print("\nType complete name>>\n")
44+
anime_name = input(
45+
"[+] Enter the name of the Anime : ").strip().title().replace(" ", "-")
46+
47+
print("\n")
48+
print(anime_name)
49+
50+
search_url = ("https://www.anime-planet.com/anime/" + anime_name)
51+
source_code = requests.get(search_url)
52+
content = source_code.content
53+
global soup
54+
soup = BeautifulSoup(content, features="html.parser") # to parse the selectd HTML
55+
# print(soup.prettify)
56+
57+
try:
58+
details(soup)
59+
except AttributeError:
60+
print("Anime info not found")
61+
62+
63+
if __name__ == "__main__":
64+
entry()

Anime_Tracker/anime_tracker_.png

51 KB
Loading

Anime_Tracker/readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# this is a python script for giving information about the anime like information about anime , number of episodes released till date, Years active, Tags related to it.
2+
3+
# script is built with the help of
4+
$--- bs4 module (for web scraping)
5+
$ ---requests module

0 commit comments

Comments
 (0)