jkCli/search.py

42 lines
1.1 KiB
Python

from bs4 import BeautifulSoup
import requests
def search(anime):
#etc
search_base = 'https://jkanime.net/buscar/'
filler = ['<div class="title">', '</div>', '[', ']']
final_list = []
#search
search_link = search_base + anime + '/'
#scrap
webp = requests.get(search_link)
soup = BeautifulSoup(webp.text, 'html.parser')
results = soup.find_all('div', class_ = 'title')
results = str(results)
for words in filler:
results = results.replace(words, '')
results_list = results.split(',')
#fixing names
for x in results_list:
if x[0] == ' ':
x = x.replace(' ', '', 1)
final_list.append(x)
return final_list
def episodes(link):
#scrap
webs = requests.get(link)
sopa = BeautifulSoup(webs.text, 'html.parser')
nums = sopa.find_all('div', class_ = 'anime__details__content')
#find eps
text = str(nums)
eps = text.find('Episodios:</span>')
eps2 = str(text[eps:])
split = eps2.split('</li>', 1)
half = split[0]
half = half.replace('Episodios:</span> ', '')
return half