send_arxiv.py 文件源码

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

项目:arxiv-feed-mailer 作者: basnijholt 项目源码 文件源码
def get_arxiv_mail(title_words, abstract_words, 
                   author_words, feed_url, my_mail):
    feed = feedparser.parse(feed_url)
    filtered_entries = [entry for entry in feed.entries if filter(entry)]

    msg = ["<h1>arXiv results for {}</h1>".format(date_str)]

    for entry in filtered_entries:
        msg.append('<h2>{}</h2>'.format(entry.title))
        msg.append('<h3>{}</h3>'.format(strip_html(entry.author)))
        msg.append('<p>{}</p>'.format(strip_html(entry.description)))
        num = 'arXiv:' + entry['id'].split('/')[-1]
        link = '<a href="{}">{}</a>'.format(entry['id'], num)
        pdf_link = '[<a href="{}">pdf</a>]'.format(entry.id.replace('abs', 'pdf'))
        msg.append(link + " " + pdf_link)
    keywords = ', '.join(title_words + abstract_words)
    authors = ', '.join(author_words)
    footer = ("<p><em>Selected keywords: {}. Selected authors: {}. " +
              "From feed: {}</em></p>")
    msg.append(footer.format(keywords, authors, feed_url))
    msg = "".join(msg)
    return msg
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号