search
HomeBackend DevelopmentPython TutorialPython制作CSDN免积分下载器

CSDN免积分下载 你懂的。
1、输入资源地址如:http://download.csdn.net/download/gengqkun/4127808
2、输入验证码
3、点击下载,会弹出浏览器下载。
注:成功率在70-80% ,界面很丑,请将就着用。

复制代码 代码如下:

#-*-coding:utf-8-*-
#python3.3.5
import urllib.parse,urllib.request,http.cookiejar,io,webbrowser
import tkinter as tk
from tkinter import *
from tkinter.ttk import *
from urllib.request import urlopen
from PIL import Image, ImageTk
global root
#设置cookie 
cookie = http.cookiejar.CookieJar()
cookieProc = urllib.request.HTTPCookieProcessor(cookie)
opener = urllib.request.build_opener(cookieProc)
urllib.request.install_opener(opener)
#根据路径和POST内容来提交表单
def getUrlRequest(iUrl,iStrPostData):
    postdata = urllib.parse.urlencode(iStrPostData)
    postdata = postdata.encode(encoding='UTF8')
    header = {'User-Agent':'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)'}
    req= urllib.request.Request(
               url = iUrl,
               data = postdata,
               headers = header)
    data = urllib.request.urlopen(req).read()
    try:
        data = data.decode('utf-8')
    except:
        data = data.decode('gbk', 'ignore')
    return data
#获取验证码图片
def getCodeImg():
    urlCode='http://csdn.juming.com/code.htm'
    image_bytes = urlopen(urlCode).read()
    # internal data file
    data_stream = io.BytesIO(image_bytes)
    # open as a PIL image object
    pil_image = Image.open(data_stream)
    tk_image = ImageTk.PhotoImage(pil_image)
    return tk_image
#构建界面
def createGui(msg=''):
    global root
    root = tk.Tk()
    root.title("CSDN免积分下载器 v0.1")
    root.resizable(False, False)   #禁止修改窗口大小
    root.geometry('+400+250')  #屏幕位置
    #-------------------------------------------
    tk_image = getCodeImg()
    # put the image on a typical widget
    frm_top_label = tk.Label(root,compound = 'top',image=tk_image,text="验证码图片",fg="blue",bg="brown",font=('Tempus Sans ITC',20))
    frm_top_label.grid(row = 0, column = 0, padx = 15, pady = 2)
    #-------------------------------------------
    frm_bottom = tk.LabelFrame(root)
    frm_bottom.grid(row = 1, column = 0, padx = 15, pady = 2)
    frm_bottom_label_0 = tk.Label(frm_bottom,text="下载地址:", font=('Tempus Sans ITC',15))
    frm_bottom_label_0.grid(row = 0, column = 0, padx = 5, pady = 2,sticky = "e") #控件右对齐
    frm_bottom_label_1 = tk.Label(frm_bottom,text="  验证码:", font=('Tempus Sans ITC',15))
    frm_bottom_label_1.grid(row = 1, column = 0, padx = 5, pady = 2,sticky = "e")
    frm_bottom_entry_var_0 = StringVar()
    frm_bottom_entry_0 = tk.Entry(frm_bottom,textvariable=frm_bottom_entry_var_0)
    frm_bottom_entry_0.grid(row = 0, column = 1, padx = 15, pady = 2)
    frm_bottom_entry_var_1 = StringVar()
    frm_bottom_entry_1 = tk.Entry(frm_bottom,textvariable=frm_bottom_entry_var_1) #设置密码输入框,熟悉show
    frm_bottom_entry_1.grid(row = 1, column = 1, padx = 15, pady = 2)
    frm_bottom_btn_0 = tk.Button(frm_bottom,text="下   载",relief=RIDGE,bd=4,width=10, font=('Tempus Sans ITC',12),command=lambda:downloadSource(frm_bottom_entry_var_0,frm_bottom_entry_var_1,frm_top_label,frm_foot_label))
    frm_bottom_btn_0.grid(row = 3, column = 1, padx = 15, pady = 2,sticky = "w")
    frm_foot_label = tk.Label(root,text=msg ,font=('Tempus Sans ITC',10))
    frm_foot_label.grid(row = 3, column = 0, padx = 15, pady = 2)
    root.mainloop() 
#获取下载资源地址  
def getSourceUrl(code,ziyuandz):
    #资源信息 
    strLoginInfo = {'csdn_zh': '用户名',
                    'csdn_mm': '密码',
                    're_yzm':code,
                    'ziyuandz':ziyuandz #'http://download.csdn.net/detail/shinian1987/8430743' #
                    }
    #下载资源地址
    urlLogin='http://csdn.juming.com/index.htm'
    returnHtml = str(getUrlRequest(urlLogin,strLoginInfo))
    a = returnHtml.find('电信下载地址:') + 15
    b = returnHtml.find('

网通下载地址:')
    durl = returnHtml[a:b]
    return durl
#下载资源
def downloadSource(frm_bottom_entry_var_0,frm_bottom_entry_var_1,frm_top_label,frm_foot_label):
    try:
        ziyuandz = frm_bottom_entry_var_0.get()
        code = frm_bottom_entry_var_1.get()
        durl = getSourceUrl(code,ziyuandz)
        print('资源地址:'+ durl)
        reMsg = "已经打开浏览器,请下载..."
        yzm = durl.find("验证码")
        #yzm += durl.find("验证码验证错误")
        #yzm += durl.find("验证码输入不正确")
        fs = durl.find("封杀本工具特意加")
        gs = durl.find("正确的格式如")
        jf = durl.find("成功获取到0点积分")
        xzzy = durl.find("http:")
        if fs > 0:
            reMsg = "该资源被封杀,请稍后再下载..."
        elif code=='':
            reMsg = "验证码不能为空..."
        elif ziyuandz=='':
            reMsg = "下载地址不能为空..."
        elif gs > 0:
            reMsg = "资源地址错误,请重新输入..."
        elif yzm > 0:
            reMsg = "验证码输入错误..."
        elif jf > 0:
            reMsg = "积分不足,资源无法下载..."
        elif xzzy >= 0: 
            webbrowser.open(durl, new=0, autoraise=True)
        else:
            reMsg = "资源错误或没有找到下载资源..."
        #print(xzzy)
        frm_foot_label['text'] = reMsg
        tk_image = getCodeImg()
        frm_top_label.configure(image = tk_image)
        frm_top_label.image= tk_image
    except:
        root.destroy()
        createGui('程序错误,请重新下载...')
#MAIN
createGui()

演示图片

 

以上就是本文的全部内容了,希望大家能够喜欢。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How do you slice a Python array?How do you slice a Python array?May 01, 2025 am 12:18 AM

The basic syntax for Python list slicing is list[start:stop:step]. 1.start is the first element index included, 2.stop is the first element index excluded, and 3.step determines the step size between elements. Slices are not only used to extract data, but also to modify and invert lists.

Under what circumstances might lists perform better than arrays?Under what circumstances might lists perform better than arrays?May 01, 2025 am 12:06 AM

Listsoutperformarraysin:1)dynamicsizingandfrequentinsertions/deletions,2)storingheterogeneousdata,and3)memoryefficiencyforsparsedata,butmayhaveslightperformancecostsincertainoperations.

How can you convert a Python array to a Python list?How can you convert a Python array to a Python list?May 01, 2025 am 12:05 AM

ToconvertaPythonarraytoalist,usethelist()constructororageneratorexpression.1)Importthearraymoduleandcreateanarray.2)Uselist(arr)or[xforxinarr]toconvertittoalist,consideringperformanceandmemoryefficiencyforlargedatasets.

What is the purpose of using arrays when lists exist in Python?What is the purpose of using arrays when lists exist in Python?May 01, 2025 am 12:04 AM

ChoosearraysoverlistsinPythonforbetterperformanceandmemoryefficiencyinspecificscenarios.1)Largenumericaldatasets:Arraysreducememoryusage.2)Performance-criticaloperations:Arraysofferspeedboostsfortaskslikeappendingorsearching.3)Typesafety:Arraysenforc

Explain how to iterate through the elements of a list and an array.Explain how to iterate through the elements of a list and an array.May 01, 2025 am 12:01 AM

In Python, you can use for loops, enumerate and list comprehensions to traverse lists; in Java, you can use traditional for loops and enhanced for loops to traverse arrays. 1. Python list traversal methods include: for loop, enumerate and list comprehension. 2. Java array traversal methods include: traditional for loop and enhanced for loop.

What is Python Switch Statement?What is Python Switch Statement?Apr 30, 2025 pm 02:08 PM

The article discusses Python's new "match" statement introduced in version 3.10, which serves as an equivalent to switch statements in other languages. It enhances code readability and offers performance benefits over traditional if-elif-el

What are Exception Groups in Python?What are Exception Groups in Python?Apr 30, 2025 pm 02:07 PM

Exception Groups in Python 3.11 allow handling multiple exceptions simultaneously, improving error management in concurrent scenarios and complex operations.

What are Function Annotations in Python?What are Function Annotations in Python?Apr 30, 2025 pm 02:06 PM

Function annotations in Python add metadata to functions for type checking, documentation, and IDE support. They enhance code readability, maintenance, and are crucial in API development, data science, and library creation.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment