Last active
May 15, 2019 11:15
-
-
Save OsamaMahmood/66eea6be4fe644fd768ba009532efdbb to your computer and use it in GitHub Desktop.
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
from bs4 import BeautifulSoup | |
import requests | |
file_name = "dl.txt" | |
file = open(file_name, 'wb') | |
for x in range(0,2): | |
index_url = "https://horriblesubs.info/api.php?method=getshows&type=show&showid=347&nextid="+str(x) | |
ua_string = { | |
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B179 Safari/7534.48.3' | |
} | |
response = requests.get(index_url, headers=ua_string) | |
soup = BeautifulSoup(response.text, 'html.parser') | |
link = "rls-link link-480p" | |
for div in soup.find_all('div',attrs={"class" : link}): | |
magnet = div.find('span',attrs={"class" : "dl-type hs-magnet-link"}) | |
href = magnet.find('a').get('href') | |
file.write(href.encode()+"\n") | |
print('Saved to %s' % file_name) | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment