Created
October 21, 2019 12:18
-
-
Save mahdizojaji/645ca9851883b4ebeb6ff2b6a01a95e2 to your computer and use it in GitHub Desktop.
find movie
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 requests import get | |
from bs4 import BeautifulSoup | |
from re import search | |
def get_all_urls(): | |
urls = [ | |
'http://dl8.sabadl.xyz/ali/', | |
'http://dl8.sabadl.xyz/ali/1/', | |
'http://dl8.sabadl.xyz/ali/2/', | |
'http://dl8.sabadl.xyz/ali/3/', | |
'http://dl8.sabadl.xyz/ali/4/', | |
'http://dl8.sabadl.xyz/ali/5/', | |
] | |
base_url = 'http://dl9.sabadl.xyz/film/' | |
html_response = get('http://dl9.sabadl.xyz/film/').text | |
soup = BeautifulSoup(html_response, "html.parser") | |
for tag in soup.find_all('a'): | |
if tag.text[-2].isnumeric(): | |
urls.append(base_url+tag.text) | |
return urls | |
def movie_iterate(): | |
for url in get_all_urls(): | |
response = get(url) | |
soup = BeautifulSoup(response.text, "html.parser") | |
for i in soup.find_all('a'): | |
yield {'name': i.text, 'url': url+i['href']} | |
def main(): | |
name = input('please enter your movie name: ') | |
movie_iterate() | |
for counter, movie in enumerate(movie_iterate()): | |
if search(name.lower(), movie['name'].lower()): | |
print(movie) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment