-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
53 lines (45 loc) · 1.43 KB
/
main.py
File metadata and controls
53 lines (45 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
try:
import requests, selenium
from bs4 import BeautifulSoup
except:
os.system('pip install -r requirement.txt')
import requests
from bs4 import BeautifulSoup
from episodes import find_ep
titles = {}
def find_title(soupfn):
find_soup = soupfn.find_all('p', class_='name', )
for i in find_soup:
for j in i.find_all('a'):
titles[j.get_text()] = j.attrs['href']
return titles
headers = {
'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 15_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) '
'Mobile/15E148'}
while True:
search = input('Enter searched anime: \033[1;32;20m')
link = 'https://gogoanime3.co/search.html?keyword=' + search
f = True
while f:
try:
search_source = requests.get(link, timeout=10, headers=headers)
f = 0
except:
continue
soup = BeautifulSoup(search_source.content, 'html.parser')
titles = find_title(soup)
if len(titles.keys()) == 0:
"There are no search results :("
continue
else:
break
i=0
for i in range(len(titles.keys())):
try:
print(f'\033[1;34;20m [{i + 1}]', '\033[1;35;20m',list(titles.keys())[i])
except:
break
choice = input(f"\033[0mPlease Choose (\033[1;34;20m1-{i+1}\033[0m): \033[1;32;20m")
gogolink = 'https://gogoanime3.co' + titles[list(titles.keys())[int(choice) - 1]]
find_ep(gogolink)