Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9282214
commit cbc3aba
Showing
6 changed files
with
46 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
requests==2.18.4 | ||
requests==2.20.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
from os import path | ||
|
||
|
||
VERSION = 'v1.0.3' | ||
VERSION = 'v1.0.4' | ||
|
||
here = path.abspath(path.dirname(__file__)) | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from pprint import pprint | ||
from resteasy import RESTEasy | ||
try: | ||
from html.parser import HTMLParser | ||
except ImportError: | ||
from HTMLParser import HTMLParser | ||
|
||
|
||
class MyHTMLParser(HTMLParser): | ||
'''Custom HTML parser''' | ||
|
||
def handle_starttag(self, tag, attrs): | ||
'''Overriding abstract method''' | ||
if tag == 'title' and not self.found: | ||
self.found = True | ||
|
||
def handle_data(self, data): | ||
'''Overriding abstract method''' | ||
if self.found and self.anime is None: | ||
self.anime = data | ||
|
||
def parse(self, content): | ||
'''Parse content and return object''' | ||
self.found = False | ||
self.anime = None | ||
self.feed(content) | ||
title = self.anime.strip().replace( | ||
' - MyAnimeList.net', '') if self.found else None | ||
return dict(title=title) | ||
|
||
|
||
parser = MyHTMLParser() | ||
|
||
api = RESTEasy(base_url='https://myanimelist.net', decoder=parser.parse) | ||
|
||
pprint(api.route('anime', 1).get()) |