{"id":57,"date":"2014-06-23T14:57:06","date_gmt":"2014-06-23T14:57:06","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=57"},"modified":"2014-06-23T14:57:06","modified_gmt":"2014-06-23T14:57:06","slug":"%e7%94%a8python%e8%84%9a%e6%9c%ac%e6%8a%93%e5%8f%96bing%e4%b8%bb%e9%a1%b5%e8%83%8c%e6%99%af%e5%9b%be%e7%89%87","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/57.html","title":{"rendered":"\u7528python\u811a\u672c\u6293\u53d6bing\u4e3b\u9875\u80cc\u666f\u56fe\u7247"},"content":{"rendered":"<p>\u5728\u7f51\u4e0a\u770b\u5230\u7684\u4e0d\u9519\u7684Python\u6293\u53d6\u811a\u672c\uff0c\u800c\u4e14Bing\u7684\u80cc\u666f\u56fe\u7247\u786e\u5b9e\u5f88\u4e0d\u9519\uff0c\u4e0d\u4ec5\u5982\u6b64\uff0c\u539f\u4f5c\u8005\u5199\u7684\u811a\u672c\u90a3\u4e5f\u662f\u77ed\u5c0f\u7cbe\u608d\uff0c\u503c\u5f97\u6536\u85cf\uff1a<\/p>\n<pre class=\"lang:python decode:true \">#!\/usr\/bin\/env python\n# -*- coding:utf-8 -*-\n# python\u6293\u53d6bing\u4e3b\u9875\u6240\u6709\u80cc\u666f\u56fe\u7247\n\nimport urllib, re, sys, os\n\ndef get_bing_backphoto():\n    if (os.path.exists('photos')== False):\n        os.mkdir('photos')\n\n    for i in range(0, 100):\n        url = 'http:\/\/cn.bing.com\/HPImageArchive.aspx?format=js&amp;idx=' + str(i) + '&amp;n=1&amp;nc=1361089515117&amp;FORM=HYLH1'\n        html = urllib.urlopen(url).read()\n        if html == 'null':\n            print 'open &amp; read bing error @ ' + str(i)\n            sys.exit(-1)\n        reg = re.compile('\"url\":\"(.*?)\",\"urlbase\"', re.S)\n        text = re.findall(reg, html)\n        #http:\/\/s.cn.bing.net\/az\/hprichbg\/rb\/LongJi_ZH-CN8658435963_1366x768.jpg\n        for imgurl in text:\n            right = imgurl.rindex('\/')\n            name = imgurl.replace(imgurl[:right + 1], '')\n            savepath = 'photos\/' +  name\n            urllib.urlretrieve(imgurl, savepath)\n            print name + ' save success!'\n\nget_bing_backphoto()<\/pre>\n<p>\u53ef\u4ee5\u53bb\u539f\u4f5c\u8005\u7684blog\u91cc\u9762\u770b\u4ed6\u7684\u5206\u6790\u8fc7\u7a0b\uff0c\u4e5f\u662f\u4e2a\u5b66\u4e60\u7684\u8fc7\u7a0b\u3002<\/p>\n<h6>\u539f\u6587\u94fe\u63a5\uff1a<\/h6>\n<p><a title=\"python\u6293\u53d6bing\u4e3b\u9875\u80cc\u666f\u56fe\u7247\" href=\"http:\/\/yxmhero1989.blog.163.com\/blog\/static\/112157956201311743439712\/\" target=\"_blank\">http:\/\/yxmhero1989.blog.163.com\/blog\/static\/112157956201311743439712\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u7f51\u4e0a\u770b\u5230\u7684\u4e0d\u9519\u7684Python\u6293\u53d6\u811a\u672c\uff0c\u800c\u4e14Bing\u7684\u80cc\u666f\u56fe\u7247\u786e\u5b9e\u5f88\u4e0d\u9519\uff0c\u4e0d\u4ec5\u5982\u6b64\uff0c\u539f\u4f5c\u8005\u5199\u7684\u811a\u672c\u90a3\u4e5f\u662f\u77ed\u5c0f\u7cbe [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,12],"tags":[59,8],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-programing","category-tools","tag-bing","tag-python"],"views":2789,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=57"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/57\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}