鱼C论坛

 找回密码
 立即注册
查看: 1558|回复: 3

还是pyinstaller的问题

[复制链接]
发表于 2020-12-20 23:45:56 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
不废话 直接上代码

from tkinter import *
import parsel
import time as t
import random
import requests as req
import os
import ffmpy3
from bs4 import BeautifulSoup
import re
import easygui as g
from tkinter.filedialog import askdirectory


def get_Path():
    path_ = askdirectory()
    if path_ == None:
       path_ = os.chdir(os.getcwd())
       print(path_)
    else:
       path.set(path_)
       os.chdir(path_)
       print(path_)
   
def get_movie():
    url= entry.get()
    if url == None:
        g.msgbox('网址输入有误,请重新输入!','错误')
    else:
        proxy = get_ip()
        header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1',
                  'Referer':'http://www.jisudhw.com',
                  'Origin':'http://www.jisudhw.com',
                  'Host':'www.jisudhw.com'
            }  
        
        r = req.get(url,headers = header,proxies=proxy)
        r.encoding = 'utf-8'
        html = BeautifulSoup(r.text,'lxml')
        
        # 清空textbox内容
        textzong.delete('1.0','end')
        
        
        name = html.find_all('div',class_='vodh')
        na = re.compile(r'(?<=\">).+?(?=</)')
        name1 = re.findall(r'h2\>([^\<]+)',(str(name)))
        name = str(name1[0] )
        
   
        text = html.find_all('div',class_= 'vodplayinfo')
        te = re.compile(r'(?<=\">).+?(?=</)')
        text1 = te.findall(str(text[0]))   
        b = [str(i)for i in text1]
        text1 = "".join(b)

   
        time = html.find_all('li',class_='sm')
        ti = re.compile(r'(?<=\">).+?(?=</)')
        time = ti.findall(str(time[2]))
        ti1 = re.compile(r'\d\d\d\d')
        time = str(ti1.findall(str(time)))
        a = re.findall(r'[\u4e00-\u9fa50-9]', time)
        time = ''.join(a)
        zong = str(name)+'(%s)'%str(time)+':'+str(text1)+'(来自不知名网站)'
        textzong.insert('1.0',zong)
   
def download_moive():
    url= entry.get()
    if len(url)<=0 :
        g.msgbox('网址输入有误,请重新输入!','错误')
    else:
        header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1',
                  'Referer':'http://www.jisudhw.com',
                  'Origin':'http://www.jisudhw.com',
                  'Host':'www.jisudhw.com'
            }  
        
        r = req.get(url,headers = header)
        r.encoding = 'utf-8'
        html = BeautifulSoup(r.text,'lxml')        
        for each in  html.find_all('input'):
            if 'm3u8' in each.get('value'):
                durl = each.get('value')
        
        name = html.find_all('div',class_='vodh')
        na = re.compile(r'(?<=\">).+?(?=</)')
        name1 = re.findall(r'h2\>([^\<]+)',(str(name)))
        name = str(name1[0] )
        name = '%s.mp4'%name
        ffmpy3.FFmpeg(inputs = {durl:None},outputs = {name:None}).run()
        g.msgbox(msg='已完成电影抓取!',title='通知')

def get_all():
    url= entry.get()
    if len(url)<=0 :
        g.msgbox('网址输入有误,请重新输入!','错误')
    else:
        header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1',
                  'Referer':'http://www.jisudhw.com',
                  'Origin':'http://www.jisudhw.com',
                  'Host':'www.jisudhw.com'
            }  
        
        r = req.get(url,headers = header)
        r.encoding = 'utf-8'
        html = BeautifulSoup(r.text,'lxml')
         
        name = html.find_all('div',class_='vodh')
        na = re.compile(r'(?<=\">).+?(?=</)')
        name1 = re.findall(r'h2\>([^\<]+)',(str(name)))
        name = str(name1[0] )

   
        text = html.find_all('div',class_= 'vodplayinfo')
        te = re.compile(r'(?<=\">).+?(?=</)')
        text1 = te.findall(str(text[0]))   
        b = [str(i)for i in text1]
        text1 = "".join(b)

   
        time = html.find_all('li',class_='sm')
        ti = re.compile(r'(?<=\">).+?(?=</)')
        time = ti.findall(str(time[2]))
        ti1 = re.compile(r'\d\d\d\d')
        time = str(ti1.findall(str(time)))
        a = re.findall(r'[\u4e00-\u9fa50-9]', time)
        time = ''.join(a)
        zong = str(name)+'(%s)'%str(time)+':'+str(text1)+'(来自不知名网站)'
        with open ('%s.txt'%str(name),'wb') as f:
            f.write(bytes(zong,'UTF-8'))
        
        for each in  html.find_all('input'):
            if 'm3u8' in each.get('value'):
                durl = each.get('value')               
        name = '%s.mp4'%name
        ffmpy3.FFmpeg(inputs = {durl:None},outputs = {name:None}).run()
        g.msgbox(msg='已完成电影抓取!',title='通知')
   
if __name__ == '__main__':
     
    root = Tk()
   
    root.title('视频下载助手V2.0')
    root.geometry('560x450')
    root.iconbitmap('F:\\迅雷下载\\JPTT053\\favicon.ico')
    label = Label(root,text='请输入要下载的网址:',font=('华文楷书',15))
    label.place(x=0,y=10)  
    entry = Entry(root,font=('楷书',15))
    entry.place(x=200,y=5,width=350)
    button_jiexi = Button(root,text='开始解析',font=('隶书',15),command =get_movie)
    button_jiexi.place(x=400,y=90,width=100)   
   

    labelPath = Label(root,text='当前路径:',font=('华文楷书',15))
    labelPath.place(x=0,y=50)
   
    path = StringVar()

    entryPath = Entry(root,textvariable = path,font=('华文楷书',15))
    entryPath.place(x=200,y=50,width=350)
   
   
    button1 = Button(root,text='保存路径',font=('隶书',15),command=get_Path)
    button1.place(x=50,y=90)

   
    button_jiexi = Button(root,text='开始解析',font=('隶书',15),command=get_movie)
    button_jiexi.place(x=400,y=90,width=100)   
    # ,command=get_movie
   
    button_get_movie=Button(root,text='电影下载',font=('隶书',15),command=download_moive)
    button_get_movie.place(x=50,y=140)
   
    button_get_All = Button(root,text='电影+介绍下载',font=('隶书',15),command=get_all)
    button_get_All.place(x=355,y=140)
   
    # 文本输出框
    textzong = Text(root,font=('仿宋',15))
    textzong.config(wrap=WORD)
    textzong.place(x=5,y=190,width=550,height=190)

      
    # 退出程序
    button2 = Button(root,text='退出',font=('隶书',15),command=root.quit)
    button2.place(x=250,y=400)
   

    # 显示窗口   
    root.mainloop(n=0)


代码完全可以运行 但是在打包的时候出现错误:

AttributeError: module 'win32ctypes.pywin32.win32api' has no attribute 'error'

首先我要用到的 图片是 ico格式的 是在http://www.ico51.cn/ 上转换的  尺寸是32x32的

然后 按照百度和CSDN的解决办法:
https://www.jb51.net/article/183965.htm
将Lib/site-packages/Pyinstaller目录下的compat.py文件定位到212行 并修改成了

if is_win:
  try:
    # from win32ctypes.pywin32 import pywintypes # noqa: F401
    # from win32ctypes.pywin32 import win32api
    import pywintypes
    import win32api
  except ImportError:
    xxxx
    xxxx
再运行时的确不报上述错误了 改成了pip install xxxx

现在请问各位大佬 有没有好的解决办法?













小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2020-12-21 11:38:28 | 显示全部楼层
这个问题 今天早晨我自己已经解决 问题是还是出在 ico上 请大家不要相信网上的ico网址 还是要自己写一个 python的程序  
可以看下 : http://clay-atlas.com/blog/2019/ ... er-png-ico-convert/
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2020-12-21 12:49:05 | 显示全部楼层
度娘搜索Pyinstaller GUI,下个GUI版的Pyinstaller 程序打包,挺香的
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2020-12-22 19:35:22 | 显示全部楼层
笨鸟学飞 发表于 2020-12-21 12:49
度娘搜索Pyinstaller GUI,下个GUI版的Pyinstaller 程序打包,挺香的

我还真的下了一个 可是每次都打包不成功 老难过了
小甲鱼最新课程 -> https://ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-30 01:01

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表