Created
October 30, 2021 14:02
-
-
Save MossabDiae/5d893c710ed85b7e8ad04b7f7e435792 to your computer and use it in GitHub Desktop.
Extract direct urls from anime4up
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
#!/usr/bin/env python | |
import requests | |
from bs4 import BeautifulSoup | |
import click | |
def get_page(url): | |
""" | |
take url get the webgape , store it's html , return that | |
""" | |
page = requests.get(url) | |
return page | |
def geturls(webgape): | |
""" | |
take the webgape html , extract possible video formats , return that in dict {"formatname":"formaturl"} | |
""" | |
soup = BeautifulSoup(webgape.text, 'html.parser') | |
anchors = soup.select('#episode-servers li a') | |
urls_dict = {} | |
for a in anchors: | |
urls_dict[a.get_text()] = a.get('data-ep-url') | |
return urls_dict | |
@click.command() | |
@click.argument("url") | |
def print_urls(url): | |
page = get_page(url) | |
urls = geturls(page) | |
for server_name, url in urls.items(): | |
print(f"{server_name} : {url}") | |
#print the result | |
if __name__ == "__main__": | |
print_urls() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment