Python-made csdn free Point downloader

Source: Internet
Author: User
CSDN Free points Download you understand.
1, enter the resource address such as: http://download.csdn.net/download/gengqkun/4127808
2. Enter the verification code
3, click to download, will pop up the browser download.
Note: The success rate in 70-80%, the interface is very ugly, please use.

Copy the Code code as follows:


#-*-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 Free Point Downloader 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= "Captcha picture", fg= "Blue", bg= "Brown", font= (' Tempus Sans ITC ', 20))
Frm_top_label.grid (row = 0, column = 0, PADX = Pady = 2)
#-------------------------------------------
Frm_bottom = Tk. Labelframe (Root)
Frm_bottom.grid (row = 1, column = 0, PADX = Pady = 2)
Frm_bottom_label_0 = Tk. Label (frm_bottom,text= "Download Address:", 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= "Verification Code:", 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 = Pady = 2)
frm_bottom_entry_var_1 = Stringvar ()
Frm_bottom_entry_1 = Tk. Entry (frm_bottom,textvariable=frm_bottom_entry_var_1) #设置密码输入框, familiar with show
Frm_bottom_entry_1.grid (row = 1, column = 1, PADX = Pady = 2)
Frm_bottom_btn_0 = Tk. button (frm_bottom,text= "Download", relief=ridge,bd=4,width=10, font= (' Tempus Sans ITC '), 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 =, 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 = Pady = 2)
Root.mainloop ()
#获取下载资源地址
def getsourceurl (Code,ziyuandz):
#资源信息
Strlogininfo = {' Csdn_zh ': ' username ',
' csdn_mm ': ' Password ',
' 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 (' Telecom download Address: ') + 15
b = Returnhtml.find ('

Netcom Download Address: ')
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 (' Resource address: ' + durl)
Remsg = "Already open browser, please download ..."
Yzm = Durl.find ("Verification Code")
#yzm + = Durl.find ("Captcha validation Error")
#yzm + = Durl.find ("Incorrect CAPTCHA input")
FS = Durl.find ("Kill this tool intentionally added")
GS = durl.find ("correct format as")
JF = Durl.find ("successfully acquired to 0 points")
Xzzy = Durl.find ("http:")
If FS > 0:
remsg = "The resource is blocked, please download it later ..."
Elif code== ':
Remsg = "Verification code cannot be empty ..."
Elif ziyuandz== ':
remsg = "Download address cannot be empty ..."
Elif GS > 0:
Remsg = "Resource address error, please reenter ..."
Elif yzm > 0:
Remsg = "Verification Code input error ..."
Elif JF > 0:
Remsg = "Insufficient points, resources cannot be downloaded ..."
Elif xzzy >= 0:
Webbrowser.open (Durl, new=0, Autoraise=true)
Else
remsg = "Resource error or no download resource found ..."
#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 (' program error, please re-download ... ')
#MAIN
Creategui ()

Demo pictures

The above is the whole content of this article, I hope you can enjoy.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.