websearch.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:jarvis 作者: anqxyr 项目源码 文件源码
def tvtropes(inp, *, query):
    """Show laconic description of the trope, and a link to the full page."""
    query = query.title().replace(' ', '')
    baseurl = 'http://tvtropes.org/{}/' + query
    url = baseurl.format('Laconic')
    soup = bs4.BeautifulSoup(requests.get(url).text, 'lxml')
    text = soup.find(class_='page-content').find('hr')
    if text is None:
        return lex.tvtropes.not_found
    text = reversed(list(text.previous_siblings))
    text = [i.text if hasattr(i, 'text') else i for i in text]
    text = [str(i).strip() for i in text]
    return '{} {}'.format(' '.join(text), baseurl.format('Main'))

###############################################################################
# Kaktuskast
###############################################################################
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号