{"id":1537,"date":"2015-05-25T12:38:52","date_gmt":"2015-05-25T04:38:52","guid":{"rendered":"http:\/\/boweihe.me\/?p=1537"},"modified":"2015-05-25T12:38:52","modified_gmt":"2015-05-25T04:38:52","slug":"%e6%90%ad%e5%bb%ba%e8%87%aa%e5%b7%b1%e7%9a%84openwrt%e5%b0%8f%e9%95%9c%e5%83%8f%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/dayandcarrot.space\/?p=1537","title":{"rendered":"\u642d\u5efa\u81ea\u5df1\u7684openwrt\u5c0f\u955c\u50cf\u670d\u52a1\u5668"},"content":{"rendered":"<p>\u867d\u7136\u5f53\u6211\u5199\u5b8c\u7684\u65f6\u5019\u6211\u53d1\u73b0wget\u53ef\u4ee5\u4e00\u53e5\u8bdd\u89e3\u51b3\u8fd9\u4e2a\u4e8b\u60c5\uff0c\u4e0d\u8fc7\u8fd8\u662f\u4e0e\u5927\u5bb6\u5206\u4eab\u4e0b\u4ee3\u7801\u5427~<br \/>\n\u66f4\u7b80\u5355\u7684\u65b9\u6cd5\u8be6\u89c1:<a href=\"http:\/\/zqhong.qiniudn.com\/2014\/10\/18\/%E6%90%AD%E5%BB%BAOpenWrt%E6%9C%AC%E5%9C%B0%E8%BD%AF%E4%BB%B6%E5%BA%93%E9%95%9C%E5%83%8F\/\" target=\"_blank\" rel=\"noopener noreferrer\">http:\/\/zqhong.qiniudn.com\/2014\/10\/18\/%E6%90%AD%E5%BB%BAOpenWrt%E6%9C%AC%E5%9C%B0%E8%BD%AF%E4%BB%B6%E5%BA%93%E9%95%9C%E5%83%8F\/<\/a><br \/>\n\u4e0b\u9762\u662f\u6211\u5199\u7684\u5c0f\u722c\u866b\uff0c\u662f\u5728\u5176\u4ed6\u4eba\u7684\u6210\u679c\u57fa\u7840\u4e0a\u6539\u7684\uff0c\u65b0\u589e\u652f\u6301\u7ea7\u8054\u76ee\u5f55<br \/>\n&nbsp;<\/p>\n<pre class=\"h-align:1 tab-convert:true lang:default decode:true \">#!\/usr\/bin\/env python\n#coding=utf-8\n#\n# Openwrt Package Grabber\n#\n# Copyright (C) 2015 http:\/\/boweihe.me\n# based on http:\/\/shuyz.com\n#\nimport urllib2\nimport os\nimport re\ndef fetch_package(url, subdir=''):\n    print 'fetching package list from ' + url\n    content = urllib2.urlopen(url, timeout=15).read()\n    pattern = r'&lt;a href=\"(.*?)\"&gt;'\n    items = re.findall(pattern, content)\n    for item in items:\n        if item=='..\/':\n            continue\n        else:\n            m = re.match(r'\\w+\/$', item)\n            if m:\n                if not os.path.exists(savedir + subdir + m.group()):\n                    print 'makedir ' + m.group()\n                    os.makedirs(savedir + subdir + m.group())\n                fetch_package(url + m.group(), subdir + m.group())\n            else:\n                print 'downloading item : '+ item\n                rfile = urllib2.urlopen(url + item)\n                opendir = savedir + subdir + item\n                with open(opendir, 'wb') as code:\n                    code.write(rfile.read())\n# the url of package list page, end with \"\/\"\nbaseurl = 'http:\/\/downloads.openwrt.org\/barrier_breaker\/14.07\/ar71xx\/'\n# which directory to save all the packages, end with \"\/\"\nsavedir = '.\/download-full1407\/'\nif not os.path.exists(savedir):\n    os.makedirs(savedir)\nfetch_package(baseurl)\nprint 'done!'\n<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u867d\u7136\u5f53\u6211\u5199\u5b8c\u7684\u65f6\u5019\u6211\u53d1\u73b0wget\u53ef\u4ee5\u4e00\u53e5\u8bdd\u89e3\u51b3\u8fd9\u4e2a\u4e8b\u60c5\uff0c\u4e0d\u8fc7\u8fd8\u662f\u4e0e\u5927\u5bb6\u5206\u4eab\u4e0b\u4ee3\u7801\u5427~ \u66f4\u7b80\u5355\u7684\u65b9\u6cd5\u8be6\u89c1:http:\/\/zqhong.qiniudn.com\/2014\/10\/18\/%E6%90%AD%E5%BB%BAOpenWrt%E6%9C%AC%E5%9C%B0%E8%BD%AF%E4%BB%B6%E5%BA%93%E9%95%9C%E5%83%8F\/ \u4e0b\u9762\u662f\u6211\u5199\u7684\u5c0f\u722c\u866b\uff0c\u662f\u5728\u5176\u4ed6\u4eba\u7684\u6210\u679c\u57fa\u7840\u4e0a\u6539\u7684\uff0c\u65b0\u589e\u652f\u6301\u7ea7\u8054\u76ee\u5f55 &nbsp; #!\/usr\/bin\/env python #coding=utf-8 # # Openwrt Package Grabber # # Copyright (C) 2015 http:\/\/boweihe.me # based on http:\/\/shuyz.com # import urllib2 import os import re def fetch_package(url, subdir=&#8221;): print &#8216;fetching package list from &#8216; + url content = urllib2.urlopen(url, timeout=15).read() pattern = r'&lt;a href=&#8221;(.*?)&#8221;&gt;&#8217; items = re.findall(pattern, content) for item in [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[82,89],"class_list":["post-1537","post","type-post","status-publish","format-standard","hentry","category-technical","tag-openwrt","tag-python"],"_links":{"self":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1537","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1537"}],"version-history":[{"count":0,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=\/wp\/v2\/posts\/1537\/revisions"}],"wp:attachment":[{"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dayandcarrot.space\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}