Skip to content

Instantly share code, notes, and snippets.

@MossabDiae
Created October 30, 2021 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MossabDiae/5d893c710ed85b7e8ad04b7f7e435792 to your computer and use it in GitHub Desktop.
Save MossabDiae/5d893c710ed85b7e8ad04b7f7e435792 to your computer and use it in GitHub Desktop.
Extract direct urls from anime4up
#!/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