Last active
December 21, 2015 08:59
-
-
Save Chairo/6282401 to your computer and use it in GitHub Desktop.
Python搭建BT资源搜索站(一)
This file contains hidden or 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:utf-8 -*- | |
import requests #引入requests第三方库支持 | |
#定义一个函数,下载torrage.com上的文件 | |
def download(): | |
_url = 'http://torrage.com/sync/20130820.txt' #要下载的文件 | |
_content = requests.get(_url, timeout=3).content #通过requests抓取到要下载的文件的具体内容 | |
open('20130820.txt', 'wb').write(_content) #保存到e:\python\01hg\bt-search\这个目录下(需提前建好这个目录) | |
if __name__ == "__main__": | |
download() #执行download函数 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment