Created
April 30, 2013 03:56
-
-
Save NoAnyLove/5486511 to your computer and use it in GitHub Desktop.
免费下载CSDN资源的代码,需要requests(好吧,我承认主要是因为我太懒了,已经记不到怎么用urllib来访问网页了,Orz),输入类似于http://download.csdn.net/detail/lyx_520/5312049的网址后自动获取下载地址,并用默认浏览器自动代开下载地址。方法来源于:http://hi.baidu.com/zzhzhlzd/item/e17562db3409759a270ae7c5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding:gbk | |
from ctypes import * | |
import requests | |
_down='http://download.csdn.net/index.php/rest/source/getsourceinfo/' | |
url=raw_input("输入资源地址:") | |
url=url.strip() | |
id=url[url.rfind('/')+1:] | |
print id | |
url=_down+id | |
#print url | |
payload={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0'} | |
r=requests.get(url,headers=payload) | |
#print r.text | |
js=r.json() | |
print js['title'] | |
downurl=js['url'] | |
print downurl | |
ShellExecute=windll.shell32.ShellExecuteA | |
ShellExecute.argtypes=[c_ulong, c_char_p, c_char_p, c_char_p, c_char_p, c_ulong] | |
ShellExecute(0, 'open', downurl, '', '', 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment