def get_anime_detail(path): anime = InternalDatabase.fetchone(path) if anime is None: response = request(path) document = BeautifulSoup(response.text, 'html.parser').find( 'div', class_="anime_info_body_bg") img = document.find('img')['src'].encode('utf-8').strip() title = document.find('h1').string.encode('utf-8').strip() pList = document.find_all('p', class_="type") plot = pList[1].contents[1].encode('utf-8').strip() if len( pList[1].contents) >= 2 else '' genre = "" for a in pList[2].find_all('a'): genre += a.string.encode('utf-8') try: year = pList[3].contents[1].encode('utf-8').strip() year = int(year) if year.isdigit() else None except IndexError: year = None status = pList[4].contents[1].encode('utf-8').strip() InternalDatabase.add((path, img, title, plot, genre, status, year)) anime = InternalDatabase.fetchone(path) return anime
def get_drama_detail(path): drama = InternalDatabase.fetchone(path) if drama is None: response = Get(chinaqUrl + path) response.encoding = 'utf-8' document = BeautifulSoup(response.text, 'html.parser') h1 = document.find('div', id='contain').find('h1') title = h1.contents[0][:-3].strip() img = imageUrl + path[:-1] + ".jpg" plot = getDescription(document) InternalDatabase.add((path, img, title, plot)) drama = InternalDatabase.fetchone(path) return drama
def drama_detail(path): drama = InternalDatabase.fetchone(path) if drama is None: response = request(path) document = BeautifulSoup(response.content, 'html.parser') element = document.find('div', {'class': 'details'}) year = document.find('span', text='Released:').find_next_sibling('a').text InternalDatabase.add( (path, element.find('img').attrs['src'], element.find('h1').text, element.find('span', text=re.compile( 'Description:?')).parent.find_next_sibling().text, document.find('span', text=re.compile('Country: ?')).next_sibling.strip(), document.find('span', text='Status:').find_next_sibling('a').text, int(year) if year.isdigit() else None)) drama = InternalDatabase.fetchone(path) return drama