本博客结构

  • 利用Python获取最新的sci论文摘要信息并群发邮箱
    • 1. 需要的包:biopython、markdown
    • 2. 正式代码

利用Python获取最新的sci论文摘要信息并群发邮箱

1. 需要的包:biopython、markdown

2. 正式代码

import re
import smtplib
import sys
from email.header import Header
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMETextimport markdown
from Bio import Entrez
from PyQt5.QtWidgets import QApplication, QLineEdit, QWidget, QLabel, QFormLayout, QPushButton, QFileDialog, QMessageBoxclass xia(QWidget):def __init__(self):super().__init__()  # 类初始化self.resize(1200,200)self.QPushButton1 = QPushButton("选择Term文件:")  # 添加按钮1self.QLineEdit1 = QLineEdit()  # 添加文本框1self.QPushButton2 = QPushButton("邮件接收人员:")  # 添加按钮2self.QLineEdit2 = QLineEdit()  # 添加文本框2self.QLabel1 = QLabel('邮 件  主 题 :')self.QLineEdit3 = QLineEdit()self.QPushButton3 = QPushButton("开始发送")  # 添加按钮3self.html = ''self.receiver = []layout = QFormLayout()  # 建立布局layout.addRow(self.QPushButton1, self.QLineEdit1)  # 将按钮1和文本框1加入布局layout.addRow(self.QPushButton2, self.QLineEdit2)  # 将按钮2和文本框2加入布姆layout.addRow(self.QLabel1, self.QLineEdit3)  # 将按钮2和文本框2加入布姆layout.addRow(self.QPushButton3)  # 将按钮3加入布局self.setLayout(layout)  # 将layout设定为类的布局self.QPushButton1.clicked.connect(self.term_Get)self.QPushButton2.clicked.connect(self.receiver_Get)self.QPushButton3.clicked.connect(self.operation_Run)print(self.html)@staticmethod  # 通过内部类,设定markdownpad转htmldef md2html(mdstr):exts = ['markdown.extensions.extra', 'markdown.extensions.codehilite', 'markdown.extensions.tables','markdown.extensions.toc']html = '''<html lang="zh-cn"><head><meta content="text/html; charset=utf-8" http-equiv="content-type" /><link href="default.css" rel="stylesheet"><link href="github.css" rel="stylesheet"></head><body>%s</body></html>'''ret = markdown.markdown(mdstr, extensions=exts)return html % ret@staticmethoddef html_Get(keyword):  # 获取Entrez.email = 'mlxia@tust.edu.cn'# if self.QLineEdit1.text() is None:#     reply=QMessageBox.information(self,"状态提醒","Term栏不能为空",QMessageBox.Yes|QMessageBox.No)#     return# keyword = self.QLineEdit1.text()handle = Entrez.esearch(db='pubmed', term=keyword)record = Entrez.read(handle)result = record['IdList']print(result)handle2 = Entrez.efetch(db='pubmed', rettype='abstract', id=result, retmode='text')html = handle2.read()html = markdown.markdown(html)return html@staticmethoddef html_Reshape(html):html2 = html.replace(html[0:9], '## ')  # 第一级题目list1 = [i.start() for i in re.finditer('## ', html2)]list2 = [i.start() for i in re.finditer('</li>\n</ol>', html2)]list1.reverse()list2.reverse()for i in range(len(list1)):str1 = html2[:list1[i]]str2 = html2[list1[i] + 1:list2[i]].replace('\n', ' ') + '\n'str3 = html2[list2[i] + 12:]html2 = str1 + str2 + str3html2 = html2.replace('# ', '## ')# ----------------------------------------------------------------------page_Num = len(list1)html2 = html2.replace('doi:\n', 'doi: ')  # 题目解决完毕# ----------------------------------------------------------------------list = [i.start() for i in re.finditer('##', html2)]list.reverse()for i in list:Num4 = i + html2[i:].index('<p>')str1 = html2[0:Num4] + '### 'Num5 = i + html2[i:].index('</p>')str2 = html2[(Num4 + 3):Num5].replace('\n', '')str3 = html2[Num5:]html2 = str1 + str2 + str3  # 二级题目解决完毕# ----------------------------------------------------html2 = xia.md2html(html2)return html2@staticmethoddef email_send(receiver, subject, text):username = 'xiamenglei321@163.com'password = #此处请写自己的密码sender = 'xiamenglei321@163.com'subject = Header(subject, 'utf-8').encode()msg = MIMEMultipart('mixed')msg['Subject'] = subjectmsg['From'] = 'xiamenglei321@163.com <xiamenglei321@163.com>'msg['To'] = ";".join(receiver)text_plain = MIMEText(text, _subtype='html', _charset='utf-8')msg.attach(text_plain)smtp = smtplib.SMTP()smtp.connect('smtp.163.com')smtp.login(username, password)smtp.sendmail(sender, receiver, msg.as_string())smtp.quit()def term_Get(self):file = QFileDialog.getOpenFileName(self, '选择文件位置', '.', '*.txt')print(file[0])with open(file[0], 'r') as f:self.QLineEdit1.setText(f.read())def html_Get2(self):self.html = xia.html_Get(self.QLineEdit1.text())def receiver_Get(self):file = QFileDialog.getOpenFileName(self, '选择文件位置', '.', '*.txt')persions = []with open(file[0], 'r') as f:for i in f.readlines():persions.append(i)self.receiver = persionsself.QLineEdit2.setText(';'.join(persions))def operation_Run(self):self.html_Get2()dddd = r'<p>Supplied id parameter is empty.</p>'if self.html == dddd:reply = QMessageBox.information(self, "状态提醒", "没有论文发表", QMessageBox.Yes | QMessageBox.No)returntext=xia.html_Reshape(self.html)subject=self.QLineEdit3.text()if subject is None:reply=QMessageBox.information(self,"状态提醒","Subject栏不能为空",QMessageBox.Yes|QMessageBox.No)returnxia.email_send(self.receiver, subject, text)reply = QMessageBox.information(self, "状态提醒", "已经发送完毕!", QMessageBox.Yes | QMessageBox.No)
if __name__ == '__main__':app = QApplication(sys.argv)win = xia()win.show()sys.exit(app.exec_())

利用Python获取最新的sci论文摘要信息并群发邮箱相关推荐

  1. 利用python获取自己的qq群成员信息!

    利用python获取自己的qq群成员信息! 首先说明一下需要使用的工具以及技术:python3 + selenium ,如有兴趣可以加群交流噢 selenium安装方法:pip install sel ...

  2. 利用python获取王者荣耀英雄的相关信息

    游戏,是用来放松身心的,也有很多人对游戏研究很深,今天我们就用python获取农药上的英雄的部分信息吧 # author: .Edgar # date: 3/8 # version: 1.0.0imp ...

  3. 如何写好SCI论文摘要和文章内容 - 易智编译EaseEditing

    在这篇文章中,易智编译整理了关于如何写好SCI论文摘要和如何发表高质量文章两大版块,供大家参考,希望能给大家提供些许解决问题的思路. 如果有任何关于SCI论文相关的问题,欢迎大家来易智编译进行咨询,易 ...

  4. 利用python获取微信企业号打卡数据,并生成windows计划任务

    利用python获取微信企业号打卡数据,并生成windows计划任务 安装python 安装第三方库 写主程序 设置Windows计划任务 由于公司的系统用的是Java版本,开通了企业号打卡之后又没有 ...

  5. 在Linux上利用python获取本机ip

    下面介绍在Linux上利用python获取本机ip的方法. 经过网上调查, 发现大致有两种方法, 一种是调用shell脚本,另一种是利用python中的socket等模块来得到,下面是这两种方法的源码 ...

  6. python过去日期_利用python获取当前日期前后N天或N月日期的方法示例

    前言 最近因为工作原因,发现一个Python的时间组件,很好用分享出来!(忘记作者名字了,在这里先感谢了),下面话不多说,来一起看看详细的介绍吧. 示例代码: # -*- coding: utf-8 ...

  7. Python语言学习:利用python获取当前/上级/上上级目录路径(获取路径下的最后叶目录的文件名、合并两个不同路径下图片文件名等目录/路径案例、正确加载图片路径)之详细攻略

    Python语言学习:利用python获取当前/上级/上上级目录路径(获取路径下的最后叶目录的文件名.合并两个不同路径下图片文件名等目录/路径案例.正确加载图片路径)之详细攻略 目录 利用python ...

  8. python自动保存ping结果_利用python获取Ping结果示例代码

    前言 本文主要跟大家分享了关于利用python获取Ping结果的相关内容,分享出来供大家参考学习,下面话不多说,来一起看看详细的介绍吧. 示例代码: # -*- coding: utf-8 -*- i ...

  9. python读取sas数据集_利用Python获取SAS和R自带数据集

    图:北京-奥森公园-2018年4月 无论是SAS.R还是Python,本身都自带一些数据集,对于初学者来说,可以通过这些自带的小数据集进行编程练习,无疑是非常方便的.SAS.R作为统计分析软件,本身自 ...

最新文章

  1. fft ocean注解
  2. 获取控制台窗口的句柄(HWND)和程序中输出回车键
  3. Java多线程之集合类(线程安全和不安全)
  4. ZOJ 2165 Red and Black
  5. 18awg线材最大电流_小米生态链拉车线:2.4A大电流,苹果MFi认证,高速充电不断裂...
  6. 信号与系统sa函数求积分_瞎扯数学分析微积分(1~4)
  7. Android开发中常见的内存泄露案例以及解决方法总结
  8. 机器视觉核心算法——图像预处理
  9. mybatis写增删改时候的注意点
  10. redis 慢消费_Redis精进:List的使用和应用场景
  11. 修改docx表格_文件杂乱怎么办?批量整理修改文件名我就用它
  12. axure导入的元件库不见了_Axure教程丨制作自己的Axure元件库
  13. matlab 求副瓣电平,一种阵列天线一维方向图的副瓣电平计算方法与流程
  14. jar中没有主清单属性
  15. php支付宝接口开发流程,对接支付宝支付接口开发详细步骤(证书签名方式)
  16. 利用python合并关联两个表中的数据
  17. HC32l130单片机的delay函数怎么写
  18. 标题标签<h1></h1>和段落标签<p>
  19. 腾讯邮箱 新浪邮箱 网易 免费企业邮箱 阿里云/万网域名MX解析配置
  20. mc服务器钓鱼系统,钓鱼 - Minecraft Wiki,最详细的官方我的世界百科

热门文章

  1. 6.2 用迹求特征多项式
  2. 创客学院9天C语言四
  3. 2018吉大计算机学院复试线,吉林大学2018年考研复试分数线【已公布】
  4. 《海王》电影观后小感
  5. 资产监测设备研发中,遇到的VCC、VDD、VEE、VSS都是什么意思?
  6. 借款久期还款久期 简述
  7. 手把手教你搭建个人技术博客,半小时搞定
  8. 教你用Python做二维码
  9. 华三路由交换配置命令_H3C的路由器配置命令详解
  10. CF765F Souvenirs