{"id":871,"date":"2018-07-17T18:20:43","date_gmt":"2018-07-17T10:20:43","guid":{"rendered":"http:\/\/www.sniper97.cn\/?p=871"},"modified":"2018-07-17T18:20:43","modified_gmt":"2018-07-17T10:20:43","slug":"%e7%ac%ac%e5%8d%81%e4%b8%83%e8%ae%b2%ef%bc%9a%e6%ad%a3%e5%88%99%e8%a1%a8%e8%be%be%e5%bc%8f01","status":"publish","type":"post","link":"http:\/\/www.sniper97.cn\/index.php\/note\/python\/871\/","title":{"rendered":"\u7b2c\u5341\u4e03\u8bb2\uff1a\u6b63\u5219\u8868\u8fbe\u5f0f01"},"content":{"rendered":"<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\"># -*- coding:utf-8 -*-\n# \u6b63\u5219\u8868\u8fbe\u5f0f01\nimport re  # \u6b63\u5219\u8868\u8fbe\u5f0f\u5305\nm = re.findall(\"abc\", \"aaaaabcccabcc\")\nprint(m)\nm = re.findall(\"\\d\", \"123abc1234abc\")\n# print m\nm = re.findall(\"\\d\\d\\d\\d\", \"123abc1234abc\")\n# print m\nm = re.findall(r\"&lt;div&gt;(.*)&lt;\/div&gt;\", \"&lt;div&gt;hello&lt;\/div&gt;\")  # r\u7684\u610f\u601d\u662f\u539f\u59cb\u7684 \u6ca1\u6709\u7ecf\u8fc7\u8f6c\u4e49\n# print m\nm = re.findall(r\"&lt;div&gt;(.*)&lt;\/div&gt;\", \"&lt;div&gt;hello&lt;\/div&gt;&lt;div&gt;world&lt;\/div&gt;\")  # \u8d2a\u5a6a\u5339\u914d\n# print m\nm = re.findall(r\"&lt;div&gt;(.*?)&lt;\/div&gt;\", \"&lt;div&gt;hello&lt;\/div&gt;&lt;div&gt;world&lt;\/div&gt;\")  # \u975e\u8d2a\u5a6a\u6a21\u5f0f\uff08\u52a0\u4e2a\u201c\uff1f\u201d\uff09\n# print m\n# import urllib2  # \u722c\u866b\u7684\u5305\n#\n# res = urllib2.urlopen('http:\/\/blog.leanote.com\/qq-alan')\n# ret = res.read()\n# # m = re.findall(r'title=\"\u5168\u6587\"&gt;(.*?)&lt;\/a&gt;', ret)\n# # m = re.findall(r'title=\"\u5168\u6587\"&gt;(.*)&lt;\/a&gt;', ret,re.S)\n# m = re.findall(r'&lt;div class=\"title\"&gt;.*?title=\"\u5168\u6587\"&gt;(.*?)&lt;\/a&gt;', ret, re.S)  # re.S \u591a\u884c\u90fd\u53ef\u4ee5\u7b97\u4f5c\u4e00\u4e2a\u5b57\u7b26\u4e32(\u4e0d\u533a\u522b\\n\n# for t in m:\n# # print t.strip()\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p># -*- coding:utf-8 -*- # \u6b63\u5219\u8868\u8fbe\u5f0f01 import re # \u6b63\u5219\u8868\u8fbe\u5f0f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[24],"tags":[],"views":4304,"_links":{"self":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/871"}],"collection":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/comments?post=871"}],"version-history":[{"count":0,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/posts\/871\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/media?parent=871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/categories?post=871"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.sniper97.cn\/index.php\/wp-json\/wp\/v2\/tags?post=871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}