fundsearcher.zip-电信文档类资源-CSDN下载https://download.csdn.net/download/WASEFADG/20364256

# -*- coding:utf-8 -*-
#!/usr/bin/env python   coded by yongsheng cao 2019
import os
from reportlab.lib.pagesizes import A4, landscape
from reportlab.pdfgen import canvas
from tkinter import *
import tkinter.messagebox
import requests
import urllib
import webbrowser
import time
import shutil

# 图片文件名称列表
IMAGEFILES = []
class pdfTk(object):
    def __init__(self):
      '''用于生成主界面用于填写'''
      self.top = Tk()
      self.sw = self.top.winfo_screenwidth()
      self.sh = self.top.winfo_screenheight()
      self.topw = 500
      self.toph = 200
      self.top.title('国家自然基金本下载器_code by cys')
      self.top.geometry("%dx%d+%d+%d" % (self.topw, self.toph, (self.sw - self.topw) / 2, (self.sh - self.toph) / 2))
      self._DIRPATH = StringVar(self.top)
      self.emptfmone = Frame(self.top, height=50)
      self.emptfmone.pack()
      self.dirfm = Frame(self.top)

self.urlLabel = Label(self.dirfm, width=20,text='点击登录NSFC共享网',fg='red')
      #self.urlLabel.place(x=200, y=10)
      self.urlLabel.bind("<Button-1>", self.open_url)
      self.urlLabel.pack()
      self.descriptLabel = Label(self.dirfm, width=12, text='批准号:')
      self.descriptLabel.pack(side=LEFT)
      self.dirn = Entry(self.dirfm, width=50, textvariable=self._DIRPATH)
      #self.dirn.bind('<Return>', self.setPath)
      self.dirn.pack(side=LEFT)
      self.dirfm.pack()
      self.emptfmtwo = Frame(self.top, height=30)
      self.emptfmtwo.pack()
      self.btnfm = Frame(self.top)
      self.converBtn = Button(self.btnfm, width=10, text='生成PDF', command=self.doneAnyThing,
                           activeforeground='white', activebackground='blue')
      self.quitBtn = Button(self.btnfm, width=10, text='退出', command=self.top.quit, activeforeground='white',
                   activebackground='blue')
      self.converBtn.pack(side=LEFT, padx=10)
      self.quitBtn.pack(side=LEFT, padx=10)
      self.btnfm.pack()
      #self.text1=Entry(self.top,width=60)
      #self.text1.pack(side=LEFT, padx=150)
      # 设置label标签
      # 此处必须注意,绑定的事件函数中必须要包含event参数

def open_url(self,event):
        webbrowser.open("http://output.nsfc.gov.cn/", new=0)

def getSogouImag(self,length, path):
       n = length
       imgs_url = []
       #path0='http://output.nsfc.gov.cn/report/51/51305437_'
       path0='http://output.nsfc.gov.cn/report/'+self._DIRPATH.get()[0:2]+'/'+self._DIRPATH.get()+'_'
       for cys_i in range(1, n):
           img_url = path0 + str(cys_i) + '.png'
           r = requests.get(img_url, timeout=5)
           code = r.status_code
           if code == 404:
               break
           else:
               imgs_url.append(img_url)
       m = 0
       for img_url in imgs_url:
           print('***** ' + str(m) + '.png *****' + '   Downloading...')
           #self.text1.insert('1.0', "***** ' + str(m) + '.png *****' + '   Downloading...\n")
           urllib.request.urlretrieve(img_url, path + str(m) + '.jpg')
           m = m + 1
       print('Download image complete!')
       #self.text1.insert('1.0', "Download image complete!\n")

def doneAnyThing(self):
        #if os.path.exists("d://download//cysfund1"):  # 判断目标是否存在
            #os.remove("d://download//cysfund1")
        os.mkdir("d://download//cysfund1")
        self.getSogouImag(50,'d:/download/cysfund1/')

self.getListImages("d://download//cysfund1//")
        if os.path.exists("d://download//cysfund_result")!=1:  # 判断目标是否存在
            os.mkdir("d://download//cysfund_result")
        pdfFile = "D://download//cysfund_result//"+ self.dateStr() + ".pdf"
        self.convertpdf(pdfFile)
        #os.remove("d://download//cysfund1") #没权限
        #shutil.rmtree("d://download//cysfund1")
    def convertpdf(self, pdfFile):
      '''多个图片合成一个pdf文件'''
      (w, h) = landscape(A4) #
      cv = canvas.Canvas(pdfFile, pagesize=landscape(A4))
      for imagePath in IMAGEFILES:
         cv.drawImage(imagePath, 0, 0, w,h)
         cv.showPage()
      cv.save()
      print('Download complete!')
      tkinter.messagebox.askokcancel(title='完成', message='Download complete!File is in D:/download/cysfund_result')

def getListImages(self, dirPath):
      '''读取指定文件夹下所有的JPEG图片,存入列表'''
      if dirPath is None or len(dirPath) == 0:
         raise ValueError('dirPath不能为空,该值为存放图片的具体路径文件夹!')
      if os.path.isfile(dirPath):
         raise ValueError('dirPath不能为具体文件,该值为存放图片的具体路径文件夹!')
      if os.path.isdir(dirPath):
         for imageName in os.listdir(dirPath):
            if imageName.endswith('.jpg') or imageName.endswith('.jpeg'):
               absPath = self.converPath(dirPath) + imageName
               IMAGEFILES.append(absPath)

def converPath(self, dirPath):
      '''用于转换路径,判断路径后是否为\\,如果有则直接输出,如果没有则添加'''
      if dirPath is None or len(dirPath) == 0:
         raise ValueError('dirPath不能为空!')
      if os.path.isfile(dirPath):
         raise ValueError('dirPath不能为具体文件,该值为文件夹路径!')
      if not str(dirPath).endswith("\\"):
         return dirPath + "\\"
      return dirPath

def dateStr(self):
      '''用于生成指定格式的日期,目的是为了拼接字符串'''
      return time.strftime("%Y-%m-%d-%H-%M-%S", time.localtime())

if __name__ == '__main__':
   '''主函数,进行启动'''
   pdfTk()
   mainloop()

【代码公开】国家自然基金下载软件相关推荐

  1. 国家自然基金标书申报体会

    2010年基金的变化: 1. 成立了医学科学部 2. 新定了学科目录(中医学.中药学.中西医结合医学分别设立学科目录) 3. 基金总额增加24%左右 4. 每个项目的资助额度增加 中标率:8-12% ...

  2. 国家自然基金上会评审若干情况介绍

    国家自然基金上会评审若干情况介绍 原文地址:http://mp.weixin.qq.com/s?__biz=MzA5OTMxMTUzMw==&mid=211415058&idx=1&a ...

  3. 国家自然基金相关资料

    文章目录 1 国家自然基金撰写指南 2 科技创新2030-"新一代人工智能"重大项目 3 模板 1 国家自然基金撰写指南   包括基本信息.摘要.各个章节等都有详细的说明:   2 ...

  4. 深度!2019年国家自然基金在线填报答疑帖

    https://zhuanlan.zhihu.com/p/55190679 火行 科研工作者:公众号firegotech 本文首发于微信公众号:火行(ID: Firegotech) 火行 基金申报期, ...

  5. 国家自然基金申请三十六计

    第一计: 审时度势 为了帮助丁香园的兄弟姐妹申请到2009年国家自然科学基金,本人联合老婆继成功申请到2007年的国基之后,再次在10月份飞来捷报,又中了2008年的国基.不是本人牛气,首先要感谢从丁 ...

  6. 教育部计算机英语怎么说,教育部课题、国家社科基金、国家自然基金的英文翻译???...

    国家省部基金英文翻译 3 国家自然科学基金(批准号: )资助的课题. Project supported by the National Natural Science Foundation of C ...

  7. 2015年到2017年 国家自然基金有关深度学习和计算机视觉的部分项目

    以下是文字版本 方便查找 项目名称 项目负责人 依托单位 视觉数据描述自动生成的关键技术研究 徐常胜 中国科学院自动化研究所 面向机器人视觉的深度学习与拟人记忆机制特征提取融合方法研究 赵晓光 中国科 ...

  8. 国家自然基金的latex模版

    https://www.latexstudio.net/archives/9729.html 但是,是否有人使用这个模版来申请基金就不知道了!

  9. 如何检索国家自然科学基金项目信息并下载结题报告

    查询项目编号 1.LetPub国家自然基金项目查询 登录网站,输入检索信息进行项目查询 查找感兴趣的项目编号及项目类型 2.国家自然科学基金共享服务网 登录网站同样可以进行快速检索,但是检索能力不如L ...

最新文章

  1. Linux_ServicesManagement_RHEL7
  2. NLP神器—Gensim
  3. css grid布局增加边框,CSS Grid中每行之后的边框
  4. GDAL工具使用示例(一)
  5. (三) OpenCV仿射变换与透射变换(Affine and Perspective Transform)
  6. jar包导出无法显示图片或者音乐_超详细微信表情包制作教程
  7. Maven Plugins
  8. 让Windows Server 2008+IIS 7+ASP.NET支持10万个同时请求
  9. Android-Studio 缓存文件夹配置
  10. SQL Server完整性备份说明
  11. Visio使用注意事项
  12. 19.Linux中字符处理sort和uniq命令详解
  13. 淘金网UCskype客服系统
  14. OpenCV在win10安装
  15. vue项目对接钉钉企业内部H5微应用
  16. ListView实现item局部刷新
  17. Qt学习之添加游戏音效
  18. MySQL事件的创建和执行
  19. 百事公司携手深圳市营养学会推广“全谷物”营养
  20. java 控制鼠标点击_java 如何实现控制鼠标点击

热门文章

  1. 为对话框添加PNG图片作为背景
  2. mysql8.0.23msi安装教程
  3. 深度学习-10:人工智能简史及三剑客
  4. 敏捷开发:敏捷的价值观
  5. 企业微信可信域名个人配置方法,个人添加企业微信可信IP方法
  6. 谁是卧底 计算机相关词汇,谁是卧底电脑版
  7. VL817S与之前其他型号的区别与改动
  8. word排版图片的一种方法
  9. 计算机专业没有对象指南针,你知道iPhone指南针、计算机的小秘密吗?
  10. 【EasyExcel】的一些用法