44from selenium .common .exceptions import WebDriverException
55import os
66import re
7+ import requests
8+ import os
9+
10+
11+ def drive_download ():
12+ version = requests .get ("http://chromedriver.storage.googleapis.com/LATEST_RELEASE" ).text
13+ zipp = requests .get (f"https://chromedriver.storage.googleapis.com/{ version } /chromedriver_win32.zip" )
14+
15+ with open ("chromedriver.zip" , "wb" ) as r :
16+ r .write (zipp .content )
17+
18+ os .system ("tar -xf chromedriver.zip" )
19+ os .remove ("chromedriver.zip" )
720
821
922def localizar_driver ():
@@ -33,6 +46,12 @@ def links_zippyshare():
3346 return lista_com_links
3447
3548
49+ if os .path .isfile ("chromedriver.exe" ):
50+ pass
51+ else :
52+ drive_download ()
53+
54+
3655print ('A execução do código pode demorar de acordo com a internet' )
3756print ()
3857url = 'https://www.anbient.com/anime/lista'
@@ -67,6 +86,7 @@ def retornar_busca():
6786 tv_anbient .append (tv [c ].get ('href' ))
6887 quantidade_anime = len (list_animes )
6988 if len (list_animes ) == 0 :
89+ print ()
7090 print ('Certifique-se que o nome está correto!' )
7191 print ()
7292
@@ -115,6 +135,7 @@ def retornar_busca():
115135 # Le o numero do episódio que ira baixar
116136 while True :
117137 try :
138+ print ()
118139 numero_episodio = int (input ('Número do episódio (-1 para voltar): ' ))
119140 if numero_episodio == - 1 :
120141 retornar_busca ()
@@ -136,4 +157,144 @@ def retornar_busca():
136157 driver .get ('https://{}{}' .format (picotado [2 ], zip ))
137158
138159retornar_busca ()
160+ from bs4 import BeautifulSoup
161+ from urllib .request import urlopen
162+ from selenium import webdriver
163+ from selenium .common .exceptions import WebDriverException
164+ import os
165+ import re
166+
167+
168+ def localizar_driver ():
169+ if os .path .isfile ('chromedriver' ) or os .path .isfile ('chromedriver.exe' ):
170+ if os .name == 'posix' :
171+ # Retorna o driver nos sistas operacionais posix(ubuntu, etc...)
172+ return webdriver .Chrome (os .getcwd () + '/chromedriver' )
173+ elif os .name == 'nt' :
174+ # Retorna o driver no sistema operacional windows
175+ return webdriver .Chrome (executable_path = os .getcwd () + '\chromedriver.exe' )
176+ else :
177+ print ('Sistema operacional, não reconhecido.' )
178+ print ('Envie o resultado abaixo para os desenvolvedores em https://github.com/hirios/raspamb/' )
179+ print (os .name )
180+ exit ()
181+ else :
182+ print ('Nao encontrei o driver na mesma pasta do arquivo\n Tentarei pela path do sistema' )
183+ return webdriver .Chrome ()
184+
185+
186+ def links_zippyshare ():
187+ soup = BeautifulSoup (driver .page_source , 'html.parser' )
188+ global lista_com_links
189+ lista_com_links = []
190+ for link in soup .find_all (href = re .compile ('zippyshare.com' )):
191+ lista_com_links .append (link ['href' ])
192+ return lista_com_links
193+
194+
195+ print ('A execução do código pode demorar de acordo com a internet' )
196+ print ()
197+ url = 'https://www.anbient.com/anime/lista'
198+
199+ html = urlopen (url )
200+ bs = BeautifulSoup (html , 'html.parser' )
201+ data = bs .find (class_ = "list" )
202+ dat = data .find_all ("a" )
203+ tv = data .find_all ("a" , href = True )
204+ # epi = data.find_all("td", {'class': 'epi'})
205+
206+ lista = []
207+
208+ for c in range (0 , len (dat )):
209+ d = dat [c ].text
210+ lista .append (str (d ).lower ())
211+
212+ def retornar_busca ():
213+ global driver
214+ global list_animes
215+
216+ quantidade_anime = 0
217+ list_animes = []
218+ tv_anbient = []
219+ while quantidade_anime == 0 :
220+ anime = input ('Nome do anime: ' ).lower ().strip ()
221+
222+ for c in range (0 , len (lista )):
223+ names = lista [c ].find (anime )
224+ if names != (- 1 ):
225+ list_animes .append (lista [c ])
226+ tv_anbient .append (tv [c ].get ('href' ))
227+ quantidade_anime = len (list_animes )
228+ if len (list_animes ) == 0 :
229+ print ()
230+ print ('Certifique-se que o nome está correto!' )
231+ print ()
232+
233+ # Imprime a lista de animes
234+ for i in range (0 , len (list_animes )):
235+ print (f'[{ i + 1 } ] { list_animes [i ].title ()} ' )
236+ print ()
237+
238+ lista_numero_animes = []
239+ while True :
240+ try :
241+ print ()
242+ numero = int (input ('Digite um número (-1 para voltar): ' ))
243+ if numero == - 1 :
244+ retornar_busca ()
245+ if (numero - 1 ) < len (list_animes ):
246+ link = 'https://www.anbient.com{}' .format (tv_anbient [numero - 1 ])
247+ # print(link)
248+ break
249+ else :
250+ print ('Numero invalido!!!\n ' )
251+ print ()
252+ except ValueError :
253+ print ('!!!!! USE APENAS NUMEROS !!!!!!' )
254+ print ()
255+ except Exception as e :
256+ print ('Tem outra coisa dando bosta aq' )
257+ print (e )
258+
259+ print ('Capturando links dos episódios...' )
260+ print ('Recomenda-se que o chromedriver esteja na mesma pasta que este script' )
261+
262+ try :
263+ driver = localizar_driver ()
264+ driver .get (link )
265+ except WebDriverException as e :
266+ print ('Ocorreu um erro' )
267+ print (e )
268+ exit ()
139269
270+ lista_links = links_zippyshare ()
271+ # Imprime a lista de animes
272+ for i in range (0 , len (lista_links )):
273+ print (f'[{ i + 1 } ] { lista_links [i ]} ' )
274+
275+ while True :
276+ # Le o numero do episódio que ira baixar
277+ while True :
278+ try :
279+ print ()
280+ numero_episodio = int (input ('Número do episódio (-1 para voltar): ' ))
281+ if numero_episodio == - 1 :
282+ retornar_busca ()
283+ elif numero_episodio <= len (lista_links ):
284+ link = lista_links [numero_episodio - 1 ]
285+ break
286+ else :
287+ print ('Episódio invalido, escolha um numero entre 1 e {}' .format (len (lista_links )))
288+ except ValueError :
289+ print ('''!!!! Atenção !!!! Erro no número''' )
290+
291+ print ('Iniciando o download' )
292+ print ()
293+ driver .get (link )
294+ sopa = BeautifulSoup (driver .page_source , 'html.parser' )
295+ zip_link = sopa .find_all ("a" , id = True )
296+ zip = zip_link [0 ].get ('href' )
297+ picotado = str (link ).split ('/' )
298+ driver .get ('https://{}{}' .format (picotado [2 ], zip ))
299+
300+ retornar_busca ()
0 commit comments