<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>Notepad++</title><link>http://xpxw.com/</link><description>Good Luck To You!</description><item><title>如何对api接口做限流</title><link>http://xpxw.com/?id=171</link><description>&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;&gt;什么是接口限流&lt;/strong&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(0, 0, 0); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: rgb(238, 238, 238); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;那么什么是限流呢？顾名思义，限流就是限制流量，包括并发的流量和一定时间内的总流量，就像你宽带包了1个G的流量，用完了就没了，所以控制你的使用频率和单次使用的总消耗。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;通过限流，我们可以很好地控制系统的qps，从而达到保护系统或者接口服务器稳定的目的。&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(0, 0, 0); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: rgb(238, 238, 238); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; visibility: visible;&quot;&gt;接口限流的常用算法&lt;/strong&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(0, 0, 0); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; background-color: rgb(238, 238, 238); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;计数器法&lt;/span&gt;&lt;/strong&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; letter-spacing: 0.544px; color: rgb(0, 0, 0); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;PingFang SC&amp;quot;, 微软雅黑, Tahoma, Arial, sans-serif; font-size: 14px; background-color: rgb(238, 238, 238); visibility: visible;&quot;/&gt;计数器法是限流算法里最简单也是最容易实现的一种算法。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;比如我们规定，对于A接口来说，我们1分钟的访问次数不能超过100个。那么我们可以这么做：在一开始的时候，我们可以设置一个计数器counter，每当一个请求过来的时候，counter就加1，如果counter的值大于100并且该请求与第一个请求的间隔时间还在1分钟之内，那么说明请求数过多；&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;如果该请求与第一个请求的间隔时间大于1分钟，且counter的值还在限流范围内，那么就重置counter。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); text-align: center; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;代码如下&lt;/strong&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;code style=&quot;margin: 0px 2px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;CounterDemo&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$first_request_time;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$request_count&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//已请求的次数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$limit&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;100&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//时间窗口内的最大请求数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$interval&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;60&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//时间窗口&amp;nbsp;s&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;__construct&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&amp;nbsp;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;first_request_time&amp;nbsp;=&amp;nbsp;time();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;grant&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$now&amp;nbsp;=&amp;nbsp;time();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($now&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;first_request_time&amp;nbsp;+&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;interval){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//时间窗口内&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;request_count&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;limit)&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;request_count++;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;true&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;false&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//超出前一个时间窗口后,&amp;nbsp;重置第一次请求时间和请求总次数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;first_request_time&amp;nbsp;=&amp;nbsp;$now;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;request_count&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;true&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$m&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;CounterDemo();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$n_success&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;for&lt;/span&gt;($i=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;$i&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;200&lt;/span&gt;;&amp;nbsp;$i++){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rt&amp;nbsp;=&amp;nbsp;$m-&amp;gt;grant();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($rt){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$n_success&amp;nbsp;++;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;echo&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;成功请求&amp;nbsp;&amp;#39;&lt;/span&gt;.$n_success.&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;&amp;nbsp;次&amp;#39;&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 16px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); font-family: -apple-system, &amp;quot;SF UI Text&amp;quot;, Arial, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif; font-size: 18px; color: rgb(77, 77, 77); line-height: 26px; font-variant-ligatures: common-ligatures;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;计数器算法很简单，但是有个严重的bug：&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;一个恶意用户在0:59时瞬间发送了100个请求，然后再1:00时又瞬间发送了100个请求，那么这个用户在2秒内发送了200个请求。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;上面我们规定1分钟最多处理100个请求， 也就是每秒1.7个请求。用户通过在时间窗口的重置节点处突发请求， 可以瞬间超过系统的承载能力，导致系统挂起或宕机。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;上面的问题，其实是因为我们统计的精度太低造成的。那么如何很好地处理这个问题呢？或者说，如何将临界问题的影响降低呢？我们可以看下面的滑动窗口算法。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;我们把一个时间窗口（一分钟）分成6份，每份（小格）代表10秒。每过10秒钟我们就把时间窗口往右滑动一格， 每一个格子都有自己独立的计数器。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;比如一个请求在0:35秒到达的时候，就会落在0:30-0:39这个区间，并将此区间的计数器加1。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;从上图可以看出, 0:59到达的100个请求会落在0:50-0:59这个灰色的格子中, 而1:00到达的100个请求会落在黄色的格子中。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;而在1:00时间统计时， 窗口会往右移动一格，那么此时的时间窗口内的请求数量一共是200个，超出了限制的100个，触发了限流，后面的100个请求被抛弃或者等待。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;如果我们把窗口时间划分越多， 比如60格，每格1s， 那么限流统计会更精确。&lt;/span&gt;&lt;/section&gt;&lt;/p&gt;&lt;h1 style=&quot;margin: 0px; padding: 0px; outline: 0px; font-weight: 400; font-size: 16px; max-width: 100%; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/h1&gt;&lt;h1 style=&quot;margin: 0px; padding: 0px; outline: 0px; font-weight: 400; font-size: 16px; max-width: 100%; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 17px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;漏桶算法 (Leaky Bucket)&lt;/strong&gt;&lt;/span&gt;&lt;/h1&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;漏桶算法(Leaky Bucket): 平滑网络上的突发流量。使其整流为一个稳定的流量。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;br/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 0px 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;有一个固定容量的桶，有水流进来，也有水流出 去。对于流进来的水来说，我们无法预计一共有多少水会流进来，也无法预计水流的速度。但是对于流出去的水来说，这个桶可以固定水流出的速率。当桶满了之后，多余的水将会溢出(多余的请求会被丢弃)。&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;简单的算法实现:&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;code style=&quot;margin: 0px 2px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;LeakyBucketDemo&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$last_req_time;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//上一次请求的时间&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$capacity;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//桶的容量&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$rate;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//水漏出的速度(个/秒)&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$water;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//当前水量(当前累积请求数)&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;__construct&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;last_req_time&amp;nbsp;=&amp;nbsp;time();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;capacity&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;100&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;rate&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;20&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;water&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;grant&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$now&amp;nbsp;=&amp;nbsp;time();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$water&amp;nbsp;=&amp;nbsp;max(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;water&amp;nbsp;-&amp;nbsp;($now&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;last_req_time)&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;rate);&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;先执行漏水，计算剩余水量&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;water&amp;nbsp;=&amp;nbsp;$water;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;last_req_time&amp;nbsp;=&amp;nbsp;$now;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($water&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;capacity){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;尝试加水,并且水还未满&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;water&amp;nbsp;+=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;true&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;水满，拒绝加水&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;false&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$m&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;LeakyBucketDemo();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$n_success&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;for&lt;/span&gt;($i=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;$i&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;500&lt;/span&gt;;&amp;nbsp;$i++){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rt&amp;nbsp;=&amp;nbsp;$m-&amp;gt;grant();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($rt){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$n_success&amp;nbsp;++;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($i&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;$i&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;100&lt;/span&gt;&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;){&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//每发起100次后暂停1s&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;echo&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;已发送&amp;#39;&lt;/span&gt;,$i,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;,&amp;nbsp;成功&amp;nbsp;&amp;#39;&lt;/span&gt;,&amp;nbsp;$n_success,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;,&amp;nbsp;sleep&amp;#39;&lt;/span&gt;.PHP_EOL;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sleep(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;echo&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;成功请求&amp;nbsp;&amp;#39;&lt;/span&gt;.$n_success.&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;&amp;nbsp;次&amp;#39;&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 16px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); font-family: -apple-system, &amp;quot;SF UI Text&amp;quot;, Arial, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif; font-size: 18px; color: rgb(77, 77, 77); line-height: 26px; font-variant-ligatures: common-ligatures;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;h1 style=&quot;margin: 0px; padding: 0px; outline: 0px; font-weight: 400; font-size: 16px; max-width: 100%; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 17px;&quot;&gt;令牌桶算法 (Token Bucket)&lt;/span&gt;&lt;/strong&gt;&lt;/h1&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 20px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: inherit; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; white-space: normal; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Segoe UI&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255); overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;令牌桶算法比漏桶算法稍显复杂。首先，我们有一个固定容量的桶，桶里存放着令牌（token）。桶一开始是空的(可用token数为0)，token以一个固定的速率r往桶里填充，直到达到桶的容量，多余的令牌将会被丢弃。每当一个请求过来时，就会尝试从桶里移除一个令牌，如果没有令牌的话，请求无法通过。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;代码实现如下:&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;code style=&quot;margin: 0px 2px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;TokenBucketDemo&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$last_req_time;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//上次请求时间&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$capacity;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//桶的容量&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$rate;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//令牌放入的速度(个/秒)&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;$tokens;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//当前可用令牌的数量&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;__construct&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;last_req_time&amp;nbsp;=&amp;nbsp;time();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;capacity&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;100&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;rate&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;20&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;tokens&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;100&lt;/span&gt;;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//开始给100个令牌&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;grant&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$now&amp;nbsp;=&amp;nbsp;time();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$tokens&amp;nbsp;=&amp;nbsp;min(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;capacity,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;tokens&amp;nbsp;+&amp;nbsp;($now&amp;nbsp;-&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;last_req_time)&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;rate);&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;计算桶里可用的令牌数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;tokens&amp;nbsp;=&amp;nbsp;$tokens;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;last_req_time&amp;nbsp;=&amp;nbsp;$now;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;tokens&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;若剩余不到1个令牌,则拒绝&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;false&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;还有令牌，领取1个令牌&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;tokens&amp;nbsp;-=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;true&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$m&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;TokenBucketDemo();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$n_success&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;for&lt;/span&gt;($i=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;$i&amp;nbsp;&amp;lt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;500&lt;/span&gt;;&amp;nbsp;$i++){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$rt&amp;nbsp;=&amp;nbsp;$m-&amp;gt;grant();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($rt){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$n_success&amp;nbsp;++;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($i&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;$i&amp;nbsp;%&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;100&lt;/span&gt;&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;){&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//每发起100次后暂停1s&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;echo&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;已发送&amp;#39;&lt;/span&gt;,$i,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;,&amp;nbsp;成功&amp;nbsp;&amp;#39;&lt;/span&gt;,&amp;nbsp;$n_success,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;,&amp;nbsp;sleep&amp;#39;&lt;/span&gt;.PHP_EOL;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;sleep(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;echo&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;成功请求&amp;nbsp;&amp;#39;&lt;/span&gt;.$n_success.&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;&amp;nbsp;次&amp;#39;&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 16px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em; letter-spacing: 0.544px; white-space: normal; font-family: -apple-system, &amp;quot;SF UI Text&amp;quot;, Arial, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif, SimHei, SimSun; font-size: 18px; color: rgb(77, 77, 77); overflow: auto hidden; background-color: rgb(255, 255, 255); line-height: 26px !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;我们可以使用redis的队列作为令牌桶容器使用，使用lPush（入队），rPop（出队），实现令牌加入与消耗的操作。&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; color: rgb(77, 77, 77); font-family: -apple-system, &amp;quot;SF UI Text&amp;quot;, Arial, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif; font-size: 18px; font-variant-ligatures: common-ligatures;&quot;/&gt;TokenBucket.php&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;code style=&quot;margin: 0px 2px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #5BDAED; word-break: inherit !important;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;* PHP基于Redis使用令牌桶算法实现接口限流，使用redis的队列作为令牌桶容器，入队（lPush）出队（rPop)作为令牌的加入与消耗操作。&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;public&amp;nbsp;&amp;nbsp;add&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;加入令牌&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;public&amp;nbsp;&amp;nbsp;get&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;获取令牌&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;public&amp;nbsp;&amp;nbsp;reset&amp;nbsp;&amp;nbsp;&amp;nbsp;重设令牌桶&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;private&amp;nbsp;connect&amp;nbsp;创建redis连接&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;class&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;TokenBucket&lt;/span&gt;&lt;/span&gt;{&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;class&amp;nbsp;start&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$_config;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;redis设定&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$_redis;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;redis对象&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$_queue;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;令牌桶&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$_max;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;最大令牌数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;初始化&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;Array&amp;nbsp;$config&amp;nbsp;redis连接设定&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;__construct&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;($config,&amp;nbsp;$queue,&amp;nbsp;$max)&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config&amp;nbsp;=&amp;nbsp;$config;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_queue&amp;nbsp;=&amp;nbsp;$queue;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_max&amp;nbsp;=&amp;nbsp;$max;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_redis&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;connect();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;加入令牌&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;&amp;nbsp;Int&amp;nbsp;$num&amp;nbsp;加入的令牌数量&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@return&lt;/span&gt;&amp;nbsp;Int&amp;nbsp;加入的数量&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;add&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;($num=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;当前剩余令牌数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$curnum&amp;nbsp;=&amp;nbsp;intval(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_redis-&amp;gt;lSize(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_queue));&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;最大令牌数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$maxnum&amp;nbsp;=&amp;nbsp;intval(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_max);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;计算最大可加入的令牌数量，不能超过最大令牌数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$num&amp;nbsp;=&amp;nbsp;$maxnum&amp;gt;=$curnum+$num?&amp;nbsp;$num&amp;nbsp;:&amp;nbsp;$maxnum-$curnum;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;加入令牌&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($num&amp;gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$token&amp;nbsp;=&amp;nbsp;array_fill(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;$num,&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_redis-&amp;gt;lPush(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_queue,&amp;nbsp;...$token);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;$num;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;获取令牌&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@return&lt;/span&gt;&amp;nbsp;Boolean&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_redis-&amp;gt;rPop(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_queue)?&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;true&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;false&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;重设令牌桶，填满令牌&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;reset&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_redis-&amp;gt;delete(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_queue);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;add(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_max);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;创建redis连接&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@return&lt;/span&gt;&amp;nbsp;Link&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;private&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;connect&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;()&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;try&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$redis&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;Redis();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$redis-&amp;gt;connect(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;host&amp;#39;&lt;/span&gt;],&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;port&amp;#39;&lt;/span&gt;],&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;timeout&amp;#39;&lt;/span&gt;],&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;reserved&amp;#39;&lt;/span&gt;],&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;retry_interval&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;auth&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$redis-&amp;gt;auth(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;auth&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$redis-&amp;gt;select(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;_config[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;index&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;catch&lt;/span&gt;(RedisException&amp;nbsp;$e){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;($e-&amp;gt;getMessage());&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;false&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;$redis;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&amp;nbsp;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #5BDAED; word-break: inherit !important;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 16px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em; letter-spacing: 0.544px; white-space: normal; font-family: -apple-system, &amp;quot;SF UI Text&amp;quot;, Arial, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif, SimHei, SimSun; font-size: 18px; color: rgb(77, 77, 77); overflow: auto hidden; background-color: rgb(255, 255, 255); line-height: 26px !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; font-size: 15px; font-weight: 700;&quot;&gt;&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); letter-spacing: 0.544px; font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; white-space: normal; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;令牌的假如与消耗&lt;/strong&gt;&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;code style=&quot;margin: 0px 2px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #5BDAED; word-break: inherit !important;&quot;&gt;&amp;lt;?php&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;演示令牌加入与消耗&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;require&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;TokenBucket.php&amp;#39;&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;redis连接设定&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$config&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;array&lt;/span&gt;(&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;host&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;localhost&amp;#39;&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;port&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;6379&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;index&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;auth&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;timeout&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;reserved&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;NULL&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;retry_interval&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;100&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;令牌桶容器&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$queue&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;mycontainer&amp;#39;&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;最大令牌数&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$max&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;5&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;创建TrafficShaper对象&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$tokenBucket&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;TokenBucket($config,&amp;nbsp;$queue,&amp;nbsp;$max);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;重设令牌桶，填满令牌&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$tokenBucket-&amp;gt;reset();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;循环获取令牌，令牌桶内只有5个令牌，因此最后3次获取失败&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;for&lt;/span&gt;($i=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;$i&amp;lt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;8&lt;/span&gt;;&amp;nbsp;$i++){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var_dump($tokenBucket-&amp;gt;get());&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;加入10个令牌，最大令牌为5，因此只能加入5个&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;$add_num&amp;nbsp;=&amp;nbsp;$tokenBucket-&amp;gt;add(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;10&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;var_dump($add_num);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;循环获取令牌，令牌桶内只有5个令牌，因此最后1次获取失败&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;for&lt;/span&gt;($i=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;$i&amp;lt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;6&lt;/span&gt;;&amp;nbsp;$i++){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;var_dump($tokenBucket-&amp;gt;get());&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #5BDAED; word-break: inherit !important;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 16px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box; overflow-wrap: break-word; clear: both; min-height: 1em; letter-spacing: 0.544px; white-space: normal; font-family: -apple-system, &amp;quot;SF UI Text&amp;quot;, Arial, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, &amp;quot;WenQuanYi Micro Hei&amp;quot;, sans-serif, SimHei, SimSun; font-size: 18px; color: rgb(77, 77, 77); overflow: auto hidden; background-color: rgb(255, 255, 255); line-height: 26px !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; letter-spacing: 0.544px; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 09 Dec 2022 10:14:16 +0800</pubDate></item><item><title>用laravel 实现 地址自动识别</title><link>http://xpxw.com/?id=170</link><description>&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; letter-spacing: 0.544px; text-align: justify; font-size: 16px; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;地址自动识别现在普遍，特别是用在快递填写地址，姓名，手机号码的时候，会把这些按照一定的规范填写后，点击自动识别后，会自动填写到各自的input。&lt;/span&gt;&lt;/section&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; letter-spacing: 0.544px; text-align: justify; font-size: 16px; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; letter-spacing: 0.544px; text-align: justify; font-size: 16px; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;最近也简单的实现了这个功能，给后台添加用户的时候，自动识别地址。其实就是先定下规则吧。以下是效果图&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; text-align: justify; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px 0em; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); text-align: center; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;img class=&quot;rich_pages __bg_gif wxw-img&quot; data-ratio=&quot;1.0272108843537415&quot; data-s=&quot;300,640&quot; data-src=&quot;http://xpxw.com/zb_users/upload/2022/07/20220726150830_36015.&quot; data-w=&quot;735&quot; _width=&quot;677px&quot; data-order=&quot;0&quot; src=&quot;https://mmbiz.qpic.cn/mmbiz_gif/QibLP1rpwH8vo8QAz4GZexib296GFicEFjEPFg3sOxtk6pGhtbzy7ZRIDIeyrN9XvMeCcxwTtgkuSWIdHIPbqnXicg/640?wx_fmt=gif&amp;wxfrom=5&amp;wx_lazy=1&quot; alt=&quot;图片&quot; data-fail=&quot;0&quot; style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; vertical-align: bottom; height: auto !important; visibility: visible !important; width: 677px !important;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;具体问题具体分析！代码实现基于laravel完成。一个laravel完整的功能得具备这些：路由route，Model, View, Controller, 我这里用的有依赖注入服务容器等功能，当然，用到地址，你首先要有地址库。。。&lt;/section&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/p&gt;&lt;p&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; text-align: justify; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: left; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;下面来看看是如何实现的，这里我只贴出核心代码&lt;/strong&gt;&lt;/strong&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; text-align: justify; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;&gt;UsersController控制器&lt;/strong&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;&gt;在这里新建构造函数，实现容器的依赖注入&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: pre-wrap; color: #FF9823; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; background-color: #282B2E; visibility: visible;&quot;&gt;UsersRepository&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important; visibility: visible;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important; visibility: visible;&quot;&gt;/**&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important; visibility: visible;&quot;&gt;@var&lt;/span&gt;&amp;nbsp;&amp;nbsp;UserRepository&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important; visibility: visible;&quot;&gt;private&lt;/span&gt;&amp;nbsp;$userRepository;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important; visibility: visible;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important; visibility: visible;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important; visibility: visible;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important; visibility: visible;&quot;&gt;__construct&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important; visibility: visible;&quot;&gt;(UsersRepository&amp;nbsp;$userRepo)&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important; visibility: visible;&quot;&gt;$this&lt;/span&gt;-&amp;gt;userRepository&amp;nbsp;=&amp;nbsp;$userRepo;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; text-align: justify; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; visibility: visible;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px; visibility: visible;&quot;&gt;接下来就新建地址识别的方法，&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; white-space: pre-wrap; color: #A9B7C6; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; background-color: #282B2E; visibility: visible; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&amp;nbsp;$discernDel&lt;/span&gt;&amp;nbsp; &amp;nbsp;接收的数据是从前端传过来的，后面再贴前端代码。&amp;nbsp; 业务代码处理交给容器&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: pre-wrap; color: #FF9823; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; background-color: #282B2E; visibility: visible;&quot;&gt;UsersRepository&lt;/span&gt;里的方法&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: pre-wrap; color: #A9B7C6; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; background-color: #282B2E; visibility: visible;&quot;&gt;getDiscern&lt;/span&gt;处理&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;Function:地址识别&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;Author:磊丰&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;Request&amp;nbsp;$request&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@return&lt;/span&gt;&amp;nbsp;\Illuminate\Contracts\Routing\ResponseFactory|\Illuminate\Http\Response|&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;\Laravel\Lumen\Http\ResponseFactory|\Symfony\Component\HttpFoundation\Response&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;getDiscern&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;(Request&amp;nbsp;$request)&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$discernDel&amp;nbsp;=&amp;nbsp;$request-&amp;gt;input(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;discernDel&amp;#39;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;try&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB::beginTransaction();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$address&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;userRepository-&amp;gt;getDiscern($discernDel);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB::commit();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;catch&lt;/span&gt;&amp;nbsp;(\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;&amp;nbsp;$e){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;DB::rollBack();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$msg&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;信息提示:&amp;quot;&lt;/span&gt;.$e-&amp;gt;getMessage().&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;，行:&amp;quot;&lt;/span&gt;.$e-&amp;gt;getLine();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;response([&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;code&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;msg&amp;#39;&lt;/span&gt;=&amp;gt;$msg]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;response([&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;code&amp;#39;&lt;/span&gt;=&amp;gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;msg&amp;#39;&lt;/span&gt;=&amp;gt;$address]);&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//地址识别完成&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;来看看&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; text-align: justify;&quot;&gt;userRepository容器处理地址识别的各种业务代码&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;Function:识别地址&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;Author:磊丰&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;public&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;getDiscern&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;($discernDel)&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;($discernDel))&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;请传入要识别的地址&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$discernDel_left&amp;nbsp;=&amp;nbsp;explode&amp;nbsp;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;[&amp;#39;&lt;/span&gt;,&amp;nbsp;$discernDel);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($discernDel_left[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;]))&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;你填写的地址规则错误,手机号码应该用[]&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$discernDel_right&amp;nbsp;=&amp;nbsp;explode&amp;nbsp;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;]&amp;#39;&lt;/span&gt;,&amp;nbsp;$discernDel_left[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($discernDel_right[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;])&amp;nbsp;||&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;($discernDel_right[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;]))&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;你填写的地址规则错误,手机号码应该用[]&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$name&amp;nbsp;=&amp;nbsp;$discernDel_left[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;($name))&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;你填写的姓名有误！&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$mobile&amp;nbsp;=&amp;nbsp;$discernDel_right[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;($mobile)&amp;nbsp;||&amp;nbsp;checkMobile($mobile)&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;)&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;你填写的手机号码格式有误！&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$address&amp;nbsp;=&amp;nbsp;trim&amp;nbsp;($discernDel_right[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;($address))&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;你填写的地址不能为空&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$var_address&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;getAddressArrar($address);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$var_address[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;name&amp;#39;&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;$name;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$var_address[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;mobile&amp;#39;&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;$mobile;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;$var_address;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;上面的方法处理手机，名称，和地址处理，地址处理有些繁杂，因为有时候填写的地址有不一样的，比如广西省，有些就填写广西壮族自治区，所以&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: pre-wrap; color: #A9B7C6; font-family: Consolas, Inconsolata, Courier, monospace; font-size: 14px; background-color: #282B2E;&quot;&gt;getAddressArrar&lt;/span&gt;方法处理地址匹配信息，根据自己的业务做调整，如下&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;Function:地址的处理&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;Author:磊丰&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;$address&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@return&lt;/span&gt;&amp;nbsp;array&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@throws&lt;/span&gt;&amp;nbsp;\Exception&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;getAddressArrar&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;($address)&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;获取所有地址递归列表&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$regions&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;getRegions();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;初始化数据&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$province&amp;nbsp;=&amp;nbsp;$city&amp;nbsp;=&amp;nbsp;$district&amp;nbsp;=&amp;nbsp;[];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;先查找省份-第一级地区&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$province&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress($address,&amp;nbsp;$regions);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($province){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$province_arr&amp;nbsp;=&amp;nbsp;[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;110000&amp;#39;&lt;/span&gt;,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;300000&amp;#39;&lt;/span&gt;,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;404100&amp;#39;&lt;/span&gt;,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;310000&amp;#39;&lt;/span&gt;];&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//4个市辖区如果地址不存在二级（市辖区，县），则特殊处理&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;请正确填写省份(市辖区)&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;查找城市-第二级地区&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$city&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress($address,&amp;nbsp;$province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//这里只处理4个市辖区，可能还有多种情况，待发现&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(in_array($province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;],$province_arr)&amp;nbsp;&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;count($city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;])&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$city&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;市辖区&amp;#39;&lt;/span&gt;,&amp;nbsp;$province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($city){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;查找地区-第三级地区&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$district&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress($address,&amp;nbsp;$city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//如果没有找到，则查找另外一个二级地区&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($district[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$city&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;县&amp;#39;&lt;/span&gt;,&amp;nbsp;$province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;查找地区-第三级地区&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$district&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress($address,&amp;nbsp;$city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($city){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;查找地区-第三级地区&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$district&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress($address,&amp;nbsp;$city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;]);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//省份不填，报错误&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;省份没填写，请检查&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;getAddressInfo($address,&amp;nbsp;$province,&amp;nbsp;$city,&amp;nbsp;$district);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;匹配正确的城市地址&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;$address&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;$city_list&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;int&amp;nbsp;$force&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;int&amp;nbsp;$str_len&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@return&lt;/span&gt;&amp;nbsp;array&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;**/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;checkAddress&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;($address,&amp;nbsp;$city_list,&amp;nbsp;$force=false,&amp;nbsp;$str_len=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;2&lt;/span&gt;)&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$num&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$list&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;array&lt;/span&gt;();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;array&lt;/span&gt;();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;遍历所有可能存在的城市&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;foreach&lt;/span&gt;&amp;nbsp;($city_list&amp;nbsp;as&amp;nbsp;$city_key=&amp;gt;$city){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$city_name&amp;nbsp;=&amp;nbsp;mb_substr($city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;],&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;,&amp;nbsp;$str_len,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;判断是否存包含当前地址字符&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$city_arr&amp;nbsp;=&amp;nbsp;explode($city_name,&amp;nbsp;$address);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;如果存在相关字眼，保存该地址的所有子地址&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(count($city_arr)&amp;nbsp;&amp;gt;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;2&lt;/span&gt;){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;必须名称长度同时达到当前比对长度&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(strlen($city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;])&amp;nbsp;&amp;lt;&amp;nbsp;$str_len){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;continue&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$num&amp;nbsp;++;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;child&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$list&amp;nbsp;=&amp;nbsp;$list&amp;nbsp;+&amp;nbsp;$city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;child&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result[]&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;array&lt;/span&gt;(&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;$city_key,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;$city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;],&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;$list,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;如果有多个存在，则加大字符匹配长度&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($num&amp;nbsp;&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;&amp;nbsp;||&amp;nbsp;$force){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$region_name1&amp;nbsp;=&amp;nbsp;$result[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$region_name2&amp;nbsp;=&amp;nbsp;$result[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(strlen($region_name1)&amp;nbsp;==&amp;nbsp;strlen($region_name2)&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;strlen($region_name1)&amp;nbsp;==&amp;nbsp;$str_len){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$region_id1&amp;nbsp;=&amp;nbsp;$result[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$region_id2&amp;nbsp;=&amp;nbsp;$result[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;][&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$index&amp;nbsp;=&amp;nbsp;$region_id1&amp;nbsp;&amp;gt;&amp;nbsp;$region_id2&amp;nbsp;?&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;&amp;nbsp;:&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result&amp;nbsp;=&amp;nbsp;$result[$index];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;$result;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;$this&lt;/span&gt;-&amp;gt;checkAddress($address,&amp;nbsp;$city_list,&amp;nbsp;$force,&amp;nbsp;$str_len+&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;][&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;list&amp;#39;&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;$list;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;$result[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;根据原地址返回详细信息&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;$address&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;$province&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;$city&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@param&lt;/span&gt;&amp;nbsp;$area&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; color: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;@return&lt;/span&gt;&amp;nbsp;array&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;**/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;getAddressInfo&lt;/span&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;($address,&amp;nbsp;$province,&amp;nbsp;$city,&amp;nbsp;$district)&lt;/span&gt;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;查找最后出现的地址&amp;nbsp;-&amp;nbsp;截取详细信息&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;请检查并正确填写省份(市辖区)&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;请检查并正确填写城市&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($district[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;请检查并正确填写区域(县/区/镇)&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$find_str&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;]){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$find_str&amp;nbsp;=&amp;nbsp;$province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;($city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;]){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$find_str&amp;nbsp;=&amp;nbsp;$city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;isset&lt;/span&gt;($district[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;])&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;$district[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;]){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$find_str&amp;nbsp;=&amp;nbsp;$district[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_name&amp;#39;&lt;/span&gt;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//&amp;nbsp;截取详细的信息&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$find_str_len&amp;nbsp;=&amp;nbsp;mb_strlen($find_str,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;for&lt;/span&gt;($i=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;;&amp;nbsp;$i&amp;lt;$find_str_len&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;-1&lt;/span&gt;;&amp;nbsp;$i++){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$substr&amp;nbsp;=&amp;nbsp;mb_substr($find_str,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;0&lt;/span&gt;,$find_str_len&amp;nbsp;-&amp;nbsp;$i,&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;utf-8&amp;#39;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$end_index&amp;nbsp;=&amp;nbsp;mb_strpos($address,&amp;nbsp;$substr);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;($end_index){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$address&amp;nbsp;=&amp;nbsp;mb_substr($address,&amp;nbsp;$end_index&amp;nbsp;+&amp;nbsp;mb_strlen($substr)&amp;nbsp;,&amp;nbsp;mb_strlen($address)&amp;nbsp;-&amp;nbsp;$end_index);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;!&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;($find_str)&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;$find_str&amp;nbsp;=&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;|\S*&amp;#39;&lt;/span&gt;&amp;nbsp;.&amp;nbsp;$find_str;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$area[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;info&amp;#39;&lt;/span&gt;]&amp;nbsp;=&amp;nbsp;preg_replace(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;/\s*|,|，|:|：{$find_str}/i&amp;quot;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;,&amp;nbsp;$address);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;empty&lt;/span&gt;($area[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;info&amp;#39;&lt;/span&gt;])){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;throw&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;new&lt;/span&gt;&amp;nbsp;\&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;Exception&lt;/span&gt;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;详细地址不存在，请检查&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;$address&amp;nbsp;=&amp;nbsp;[&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;province&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;$province[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;],&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;city&amp;#39;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;gt;&amp;nbsp;$city[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;],&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;district&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;$district[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;region_code&amp;#39;&lt;/span&gt;],&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;info&amp;#39;&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;=&amp;gt;&amp;nbsp;$area[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;info&amp;#39;&lt;/span&gt;]&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;];&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;前端html部分代码&lt;/strong&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;基本上能看得懂的。jquery用到&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: pre-wrap; color: #EEDC70; font-family: Consolas, Inconsolata, Courier, monospace; background-color: #282B2E;&quot;&gt;getDiscern();&lt;/span&gt;方法，手机号码，姓名，地址等input这里就不一一列出了。大家根据下面的jquery都能想象到&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&amp;lt;div&amp;nbsp;class=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;form-group&amp;quot;&lt;/span&gt;&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{!!&amp;nbsp;Form::label(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;discern&amp;#39;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;自动识别地址:&amp;#39;&lt;/span&gt;,[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;class&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;control-label&amp;nbsp;col-sm-2&amp;#39;&lt;/span&gt;])&amp;nbsp;!!}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div&amp;nbsp;class=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;col-sm-5&amp;quot;&lt;/span&gt;&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{!!&amp;nbsp;Form::textarea(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;discern&amp;#39;&lt;/span&gt;,&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;&amp;#39;&lt;/span&gt;,&amp;nbsp;[&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;class&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;form-textarea&amp;nbsp;form-control&amp;nbsp;form-discern&amp;#39;&lt;/span&gt;,&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;rows&amp;#39;&lt;/span&gt;&amp;nbsp;=&amp;gt;&amp;nbsp;3])&amp;nbsp;!!}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;div&amp;nbsp;class=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;col-sm-3&amp;quot;&lt;/span&gt;&amp;nbsp;style=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;height:&amp;nbsp;75px;&amp;quot;&lt;/span&gt;&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;button&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;type&lt;/span&gt;=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;button&amp;quot;&lt;/span&gt;&amp;nbsp;class=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;btn&amp;nbsp;btn-info&amp;nbsp;btn-sm&amp;nbsp;discern&amp;quot;&lt;/span&gt;&amp;nbsp;onclick=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;getDiscern();&amp;quot;&lt;/span&gt;&amp;nbsp;&amp;gt;提交识别&amp;lt;/button&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;small&amp;nbsp;class=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;ruleGet&amp;quot;&lt;/span&gt;&amp;nbsp;style=&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;color:&amp;nbsp;#676a74;&amp;quot;&lt;/span&gt;&amp;gt;*查看模板&amp;lt;/small&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/div&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;lt;/div&amp;gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;jquery代码部分&lt;/strong&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0px; outline: 0px; max-width: 100%; color: rgb(34, 34, 34); font-family: system-ui, -apple-system, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; font-size: 17px; letter-spacing: 0.544px; white-space: normal; clear: both; min-height: 1em; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 15px;&quot;&gt;ajax post后交给url：&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; white-space: pre-wrap; color: #EEDC70; font-family: Consolas, Inconsolata, Courier, monospace; background-color: #282B2E;&quot;&gt;getDiscern &lt;/span&gt;处理，这个就是上面controller的方法，success返回的数据后再追加到每个input里，最后再清除掉自动识别地址框的数据&lt;/span&gt;&lt;/section&gt;&lt;section style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; text-align: justify; white-space: normal; background-color: rgb(255, 255, 255); font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; font-size: inherit; color: inherit; line-height: inherit; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;section style=&quot;margin: 0px 8px; padding: 0.5em; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: normal !important; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); word-break: normal !important; overflow: auto !important; display: -webkit-box !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;/**&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;地址识别&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*&amp;nbsp;@returns&amp;nbsp;{boolean}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;*/&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;getDiscern&lt;/span&gt;()&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;var&lt;/span&gt;&amp;nbsp;discernDel&amp;nbsp;=&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;.form-discern&amp;quot;&lt;/span&gt;).val();&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;(!discernDel){&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;alert(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;请输入要识别的地址&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;return&lt;/span&gt;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;false&lt;/span&gt;;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$.ajax({&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;type&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;POST&amp;#39;&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;url&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;{!!&amp;nbsp;route(&amp;#39;admin.user.getDiscern&amp;#39;)&amp;nbsp;!!}&amp;quot;&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;data&lt;/span&gt;:&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;_token&amp;#39;&lt;/span&gt;:&amp;nbsp;csrf_token(),&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;discernDel&amp;#39;&lt;/span&gt;:&amp;nbsp;discernDel&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;},&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;dataType&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;json&amp;#39;&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;timeout&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;50000&lt;/span&gt;,&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #A5DA2D; word-break: inherit !important;&quot;&gt;success&lt;/span&gt;:&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; word-break: inherit !important;&quot;&gt;function&lt;/span&gt;&amp;nbsp;(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #FF9823; word-break: inherit !important;&quot;&gt;res&lt;/span&gt;)&amp;nbsp;&lt;/span&gt;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;if&lt;/span&gt;&amp;nbsp;(res.code&amp;nbsp;==&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #AE87FA; word-break: inherit !important;&quot;&gt;1&lt;/span&gt;)&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;input[name=&amp;#39;addr[linkman]&amp;#39;]&amp;quot;&lt;/span&gt;).val(res.msg.name);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;input[name=&amp;#39;user_name&amp;#39;]&amp;quot;&lt;/span&gt;).val(res.msg.mobile);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;input[name=&amp;#39;addr[address]&amp;#39;]&amp;quot;&lt;/span&gt;).val(res.msg.info);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//触发change事件&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;#province&amp;#39;&lt;/span&gt;).val(res.msg.province).trigger(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;change&amp;#39;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;#city&amp;#39;&lt;/span&gt;).val(res.msg.city).trigger(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;change&amp;#39;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;#area&amp;#39;&lt;/span&gt;).val(res.msg.district).trigger(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;#39;change&amp;#39;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #808080; word-break: inherit !important;&quot;&gt;//识别后清除&lt;/span&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;.form-discern&amp;quot;&lt;/span&gt;).val(&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #EEDC70; word-break: inherit !important;&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: inherit !important; font-size: inherit; line-height: inherit; color: #F82375; word-break: inherit !important;&quot;&gt;else&lt;/span&gt;&amp;nbsp;{&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;alert(res.msg);&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;})&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;}&lt;/section&gt;&lt;/pre&gt;&lt;/section&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Tue, 26 Jul 2022 15:07:35 +0800</pubDate></item><item><title>Homestesd中更换PHP版本</title><link>http://xpxw.com/?id=169</link><description>&lt;p&gt;CLI 执行环境的 PHP 版本切换。&lt;/p&gt;&lt;p&gt;很多教程都是使用两个命令即可：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;update-alternatives --display php //查看所有 php 版本和当前版本&lt;/p&gt;&lt;p&gt;update-alternatives --config php //执行后，会列出当前 php 所有版本和编号，输入编号，切换到执行的版本&lt;/p&gt;&lt;p&gt;假设我把 PHP 版本从 7.3 切换成了 7.4，是否可以直接通过 pecl 安装 PHP 扩展了呢，没那么简单！(需要直接正确更改 PHP 版本的直接跳到最后看步骤)。现在我要使用 pecl 安装 swoole 扩展，直接执行命令：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;pecl install swoole&lt;/p&gt;&lt;p&gt;然后发现编译采用的 api 版本依然是 php7.3 的:&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;376 source files, building&lt;/p&gt;&lt;p&gt;running: phpize&lt;/p&gt;&lt;p&gt;Configuring for:&lt;/p&gt;&lt;p&gt;PHP Api Version:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;20180731&lt;/p&gt;&lt;p&gt;Zend Module Api No:&amp;nbsp; &amp;nbsp; &amp;nbsp; 20180731&lt;/p&gt;&lt;p&gt;Zend Extension Api No:&amp;nbsp; &amp;nbsp;320180731&lt;/p&gt;&lt;p&gt;这当然不行了。直接 Ctrl + C 结束安装。&lt;/p&gt;&lt;p&gt;其实主要问题出在 PHP 编译环境上，编译环境默认还是 php7.3 的。&lt;/p&gt;&lt;p&gt;所以除了切换 PHP 本身的版本，PHP 扩展的编译环境也要相应切换。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;所以更换 CLI 运行模式下的 PHP 版本完整的步骤如下&lt;/p&gt;&lt;p&gt;切换 cli 运行模式默认的 PHP 版本：&lt;/p&gt;&lt;p&gt;sudo update-alternatives --config php&lt;/p&gt;&lt;p&gt;选择 PHP7.4 即可&lt;/p&gt;&lt;p&gt;切换 phpize 版本：&lt;/p&gt;&lt;p&gt;sudo update-alternatives --config phpize&lt;/p&gt;&lt;p&gt;选择 7.4 版本&lt;/p&gt;&lt;p&gt;切换 php-config 版本&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;sudo update-alternatives --config php-config&lt;/p&gt;&lt;p&gt;同样选择 7.4 版本&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;切换 phpdbg 版本&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;sudo update-alternatives --config phpdbg&lt;/p&gt;&lt;p&gt;同样选择 7.4 版本&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;现在重新看一下跟 php 有关的环境变量：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;ls -lha /etc/alternatives | grep php&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Thu, 02 Jun 2022 17:02:45 +0800</pubDate></item><item><title>php导入大批量csv</title><link>http://xpxw.com/?id=168</link><description>&lt;p&gt;很多时候，因为数据统计，我们需要将数据库的数据导出到Excel等文件中，以供数据人员进行查看，如果数据集不大，其实很容易；但是如果对于大数集的导出，将要考虑各种性能的问题，这里以导出数据库一百万条数据为例，
 导出时间不过20秒，值得学习的一种大数据导出方式。&lt;/p&gt;&lt;p&gt;导出思路&lt;/p&gt;&lt;p&gt;需要考虑服务器内存&lt;/p&gt;&lt;p&gt;需要考虑程序运行的最大时间&lt;/p&gt;&lt;p&gt;缺少BOM头导致乱码的处理&lt;/p&gt;&lt;p&gt;如果导出数量过大，推荐使用循环导出，每次循环这里以导出一万条为例，循环100次即可全部导出&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-php&quot;&gt;&amp;nbsp;&amp;lt;?php
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//让程序一直运行
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;set_time_limit(0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//设置程序运行内存
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ini_set(&amp;#39;memory_limit&amp;#39;,&amp;nbsp;&amp;#39;128M&amp;#39;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$fileName&amp;nbsp;=&amp;nbsp;&amp;#39;测试导出数据&amp;#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;header(&amp;#39;Content-Encoding:&amp;nbsp;UTF-8&amp;#39;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;header(&amp;quot;Content-type:application/vnd.ms-excel;charset=UTF-8&amp;quot;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;header(&amp;#39;Content-Disposition:&amp;nbsp;attachment;filename=&amp;quot;&amp;#39;&amp;nbsp;.&amp;nbsp;$fileName&amp;nbsp;.&amp;nbsp;&amp;#39;.csv&amp;quot;&amp;#39;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//打开php标准输出流
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$fp&amp;nbsp;=&amp;nbsp;fopen(&amp;#39;php://output&amp;#39;,&amp;nbsp;&amp;#39;a&amp;#39;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//添加BOM头，以UTF8编码导出CSV文件，如果文件头未添加BOM头，打开会出现乱码。
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fwrite($fp,&amp;nbsp;chr(0xEF).chr(0xBB).chr(0xBF));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//添加导出标题
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fputcsv($fp,&amp;nbsp;[&amp;#39;姓名&amp;#39;,&amp;nbsp;&amp;#39;年龄&amp;#39;,&amp;nbsp;&amp;#39;地区&amp;#39;]);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//链接数据库
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$dsn&amp;nbsp;=&amp;nbsp;&amp;quot;mysql:host=127.0.0.1;port=3306;dbname=db_www;charset=utf8&amp;quot;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$pdo&amp;nbsp;=&amp;nbsp;new&amp;nbsp;PDO($dsn,&amp;nbsp;&amp;#39;root&amp;#39;,&amp;nbsp;&amp;#39;&amp;#39;);

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$step&amp;nbsp;=&amp;nbsp;100;&amp;nbsp;//循环次数
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$nums&amp;nbsp;=&amp;nbsp;10000;&amp;nbsp;//每次导出数量

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;for($i&amp;nbsp;=&amp;nbsp;0;&amp;nbsp;$i&amp;nbsp;&amp;lt;&amp;nbsp;$step;&amp;nbsp;$i++)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$start&amp;nbsp;=&amp;nbsp;$i&amp;nbsp;*&amp;nbsp;10000;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sql&amp;nbsp;=&amp;nbsp;&amp;quot;SELECT&amp;nbsp;uname,age,city&amp;nbsp;FROM&amp;nbsp;`hd_test`&amp;nbsp;ORDER&amp;nbsp;BY&amp;nbsp;`id`&amp;nbsp;LIMIT&amp;nbsp;{$start},{$nums}&amp;quot;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$pdostatement&amp;nbsp;=&amp;nbsp;$pdo-&amp;gt;query($sql);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$result&amp;nbsp;=&amp;nbsp;$pdostatement-&amp;gt;fetchAll(PDO::FETCH_ASSOC);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;foreach&amp;nbsp;($result&amp;nbsp;as&amp;nbsp;$item)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;fputcsv($fp,&amp;nbsp;$item);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//每1万条数据就刷新缓冲区
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ob_flush();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;flush();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/pre&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Thu, 19 May 2022 09:11:45 +0800</pubDate></item><item><title>精品域名出售</title><link>http://xpxw.com/?id=167</link><description>&lt;p&gt;以下好米出售&lt;/p&gt;&lt;p&gt;看房直通车 开发直通车&amp;nbsp;www.kfztc.cn&lt;/p&gt;&lt;p&gt;看房直通车 开发直通车 www.kfztc.com&amp;nbsp;&lt;/p&gt;&lt;p&gt;在线直播 装修直播 在线招标&amp;nbsp; www.zxzb.com.cn&lt;/p&gt;&lt;p&gt;中信大学 中心大学 找小点心 中兴电信 www.zxdx.cn&lt;/p&gt;&lt;p&gt;重庆001&amp;nbsp; www.cq001.com&amp;nbsp;&lt;/p&gt;&lt;p&gt;联系邮箱&amp;nbsp;&lt;span style=&quot;font-family: &amp;quot;lucida Grande&amp;quot;, Verdana, &amp;quot;Microsoft YaHei&amp;quot;; font-size: 12px; background-color: #F4F6F8;&quot;&gt;xpxw#xpxw.com （ 替换#为@）&lt;/span&gt;&lt;/p&gt;</description><pubDate>Tue, 17 May 2022 10:21:07 +0800</pubDate></item><item><title>api开发签名验证</title><link>http://xpxw.com/?id=166</link><description>&lt;p style=&quot;margin-top: 0px; margin-bottom: 1.25rem; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; font-size: 16px; white-space: normal; letter-spacing: 0.544px; color: rgb(33, 37, 41); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;开发过程中，我们经常会与接口打交道，有的时候是调取别人网站的接口，有的时候是为他人提供自己网站的接口，但是在这调取的过程中都离不开签名验证。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 1.25rem; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; font-size: 16px; white-space: normal; letter-spacing: 0.544px; color: rgb(33, 37, 41); font-family: -apple-system, BlinkMacSystemFont, &amp;quot;Segoe UI&amp;quot;, Roboto, &amp;quot;Helvetica Neue&amp;quot;, Arial, &amp;quot;Noto Sans&amp;quot;, sans-serif, &amp;quot;Apple Color Emoji&amp;quot;, &amp;quot;Segoe UI Emoji&amp;quot;, &amp;quot;Segoe UI Symbol&amp;quot;, &amp;quot;Noto Color Emoji&amp;quot;; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;我们在设计签名验证的时候，请注意要满足以下几点：&lt;/span&gt;&lt;/p&gt;&lt;ul class=&quot; list-paddingleft-2&quot; style=&quot;padding: 0px 0px 0px 2.2em; outline: 0px; max-width: 100%; color: rgb(62, 62, 62); font-size: 16px; text-align: justify; white-space: normal; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; letter-spacing: 0.544px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;可变性：每次的签名必须是不一样的。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;时效性：每次请求的时效，过期作废等。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;唯一性：每次的签名是唯一的。&lt;/span&gt;&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;完整性：能够对传入数据进行验证，防止篡改。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;这里介绍一种方式，是目前国内互联网公司常用的一种方式，其中淘宝的支付宝支付接口、淘宝开放平台接口、腾讯开放平台等应用的一种方式。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 17px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;一、签名参数sign生成的方法&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;1步: 将所有参数（注意是所有参数），除去sign本身，以及值是空的参数，按参数名字母升序排序。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第2步: 然后把排序后的参数按参数1值1参数2值2…参数n值n（这里的参数和值必须是传输参数的原始值，不能是经过处理的，如不能将&amp;amp;quot;转成”后再拼接）的方式拼接成一个字符串。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第3步: 把分配给接入方的验证密钥key拼接在第2步得到的字符串前面。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第2步: 在上一步得到的字符串前面加上验证密钥key(这里的密钥key是接口提供方分配给接口接入方的)，然后计算md5值，得到32位字符串，然后转成大写.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第4步: 计算第3步字符串的md5值(32位)，然后转成大写,得到的字符串作为sign的值。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(62, 62, 62); font-size: 16px; text-align: justify; white-space: normal; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; letter-spacing: 0.544px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;举例：&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(62, 62, 62); font-size: 16px; white-space: normal; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; letter-spacing: 0.544px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;假设传输的数据是/interface.php?sign=sign_value&amp;amp;p2=v2&amp;amp; p1=v1&amp;amp;method=cancel&amp;amp;p3=&amp;amp;pn=vn（实际情况最好是通过post方式发送），其中sign参数对应的sign_value就是签名的值。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第一步，拼接字符串，首先去除sign参数本身，然后去除值是空的参数p3，剩下p2=v2&amp;amp;p1=v1&amp;amp;method=cancel&amp;amp; amp;pn=vn，然后按参数名字符升序排序，method=cancel&amp;amp;p1=v1&amp;amp;p2=v2&amp;amp;pn=vn.&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第二步，然后做参数名和值的拼接，最后得到methodcancelp1v1p2v2pnvn&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;第三步，在上面拼接得到的字符串前加上验证密钥key，我们假设是abc，得到新的字符串abcmethodcancelp1v1p2v2pnvn&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;第四步，然后将这个字符串进行md5计算，假设得到的是abcdef，然后转为大写，得到ABCDEF这个值即为sign签名值。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 16px;&quot;&gt;注意，计算md5之前请确保接口与接入方的字符串编码一致，如统一使用utf-8编码或者GBK编码，如果编码方式不一致则计算出来的签名会校验失败。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 20px auto 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; white-space: normal; letter-spacing: 0.544px; border-width: 0px; border-style: initial; border-color: initial; line-height: 24px; font-family: ΢���ź�, ����; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 17px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;二、签名验证方法：&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(62, 62, 62); font-size: 16px; white-space: normal; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; letter-spacing: 0.544px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;根据前面描述的签名参数sign生成的方法规则，计算得到参数的签名值，和参数中通知过来的sign对应的参数值进行对比，如果是一致的，那么就校验通过，如果不一致，说明参数被修改过。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(62, 62, 62); font-size: 16px; white-space: normal; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; letter-spacing: 0.544px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(62, 62, 62); font-size: 16px; text-align: justify; white-space: normal; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; letter-spacing: 0.544px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; outline: 0px; max-width: 100%; clear: both; min-height: 1em; color: rgb(62, 62, 62); font-size: 16px; text-align: justify; white-space: normal; font-family: -apple-system-font, BlinkMacSystemFont, &amp;quot;Helvetica Neue&amp;quot;, &amp;quot;PingFang SC&amp;quot;, &amp;quot;Hiragino Sans GB&amp;quot;, &amp;quot;Microsoft YaHei UI&amp;quot;, &amp;quot;Microsoft YaHei&amp;quot;, Arial, sans-serif; letter-spacing: 0.544px; background-color: rgb(255, 255, 255); box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important; font-size: 17px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px; outline: 0px; max-width: 100%; box-sizing: border-box !important; overflow-wrap: break-word !important;&quot;&gt;三、下面直接看代码&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;prism-highlight prism-language-php&quot;&gt;&amp;lt;?php

//&amp;nbsp;设置一个公钥(key)和私钥(secret)，公钥用于区分用户，私钥加密数据，不能公开
$key&amp;nbsp;=&amp;nbsp;&amp;quot;c4ca4238a0b923820dcc509a6f75849b&amp;quot;;
$secret&amp;nbsp;=&amp;nbsp;&amp;quot;28c8edde3d61a0411511d3b1866f0636&amp;quot;;

//&amp;nbsp;待发送的数据包
$data&amp;nbsp;=&amp;nbsp;array(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;username&amp;#39;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;#39;abc@qq.com&amp;#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;sex&amp;#39;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;#39;1&amp;#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;age&amp;#39;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;#39;16&amp;#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;addr&amp;#39;&amp;nbsp;=&amp;gt;&amp;nbsp;&amp;#39;guangzhou&amp;#39;,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;key&amp;#39;&amp;nbsp;=&amp;gt;&amp;nbsp;$key,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;timestamp&amp;#39;&amp;nbsp;=&amp;gt;&amp;nbsp;time(),
);

//&amp;nbsp;获取sign
function&amp;nbsp;getSign($secret,&amp;nbsp;$data)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;对数组的值按key排序
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ksort($data);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;生成url的形式
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$params&amp;nbsp;=&amp;nbsp;http_build_query($data);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;生成sign
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sign&amp;nbsp;=&amp;nbsp;md5($params&amp;nbsp;.&amp;nbsp;$secret);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return&amp;nbsp;$sign;
}

//&amp;nbsp;发送的数据加上sign
$data[&amp;#39;sign&amp;#39;]&amp;nbsp;=&amp;nbsp;getSign($secret,&amp;nbsp;$data);

/**
&amp;nbsp;*&amp;nbsp;后台验证sign是否合法
&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;&amp;nbsp;[type]&amp;nbsp;$secret&amp;nbsp;[description]
&amp;nbsp;*&amp;nbsp;@param&amp;nbsp;&amp;nbsp;[type]&amp;nbsp;$data&amp;nbsp;&amp;nbsp;&amp;nbsp;[description]
&amp;nbsp;*&amp;nbsp;@return&amp;nbsp;[type]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[description]
&amp;nbsp;*/
function&amp;nbsp;verifySign($secret,&amp;nbsp;$data)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;验证参数中是否有签名
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(!isset($data[&amp;#39;sign&amp;#39;])&amp;nbsp;||&amp;nbsp;!$data[&amp;#39;sign&amp;#39;])&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo&amp;nbsp;&amp;#39;发送的数据签名不存在&amp;#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;die();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(!isset($data[&amp;#39;timestamp&amp;#39;])&amp;nbsp;||&amp;nbsp;!$data[&amp;#39;timestamp&amp;#39;])&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo&amp;nbsp;&amp;#39;发送的数据参数不合法&amp;#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;die();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;验证请求，&amp;nbsp;10分钟失效
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;(time()&amp;nbsp;-&amp;nbsp;$data[&amp;#39;timestamp&amp;#39;]&amp;nbsp;&amp;gt;&amp;nbsp;600)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;echo&amp;nbsp;&amp;#39;验证失效，&amp;nbsp;请重新发送请求&amp;#39;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;die();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sign&amp;nbsp;=&amp;nbsp;$data[&amp;#39;sign&amp;#39;];
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;unset($data[&amp;#39;sign&amp;#39;]);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;ksort($data);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$params&amp;nbsp;=&amp;nbsp;http_build_query($data);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//&amp;nbsp;$secret是通过key在api的数据库中查询得到
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;$sign2&amp;nbsp;=&amp;nbsp;md5($params&amp;nbsp;.&amp;nbsp;$secret);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if&amp;nbsp;($sign&amp;nbsp;==&amp;nbsp;$sign2)&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;die(&amp;#39;验证通过&amp;#39;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;else&amp;nbsp;{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;die(&amp;#39;请求不合法&amp;#39;);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}
}
?&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Wed, 29 Dec 2021 09:10:06 +0800</pubDate></item><item><title>巧用Python脚本解决自动化图形验证码</title><link>http://xpxw.com/?id=165</link><description>&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;解决UI自动化过程中的图文验证码问题，过程大致分为两个步骤：&lt;/p&gt;&lt;ul style=&quot;margin-left: 30px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;1. 自动下载网页上指定的图片&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;2. 识别图片上的文本内容&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;本文以“识别页面上指定图片的文本“为例。&lt;/p&gt;&lt;h1 id=&quot;%E4%BB%A3%E7%A0%81%E5%AE%9E%E7%8E%B0%E6%95%88%E6%9E%9C&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 28px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;代码实现效果&lt;/strong&gt;&lt;/h1&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;15&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2Ffd155b6b404b027f76261e1eb5bb2796.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_86367.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_86367.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h1 id=&quot;%E7%8E%AF%E5%A2%83%E5%87%86%E5%A4%87&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 28px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;环境准备&lt;/strong&gt;&lt;/h1&gt;&lt;ul style=&quot;margin-left: 30px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot; class=&quot; list-paddingleft-2&quot;&gt;&lt;li&gt;&lt;p&gt;Pytesseract&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Tesseract-OCR&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;Pillow&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h2 id=&quot;%E6%89%8B%E5%8A%A8%E5%AE%89%E8%A3%85pytesseract%E5%BA%93&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;手动安装pytesseract库&lt;/h2&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;命令：&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_codeSnippet cke_widget_selected&quot; data-cke-display-name=&quot;代码段&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;14&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;pre class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22lang%22%3A%22python%22%2C%22code%22%3A%22pip%20install%20pytesseract%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;codeSnippet&quot; style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; overflow: auto;&quot;&gt;pip&amp;nbsp;install&amp;nbsp;pytesseract&lt;/pre&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;13&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F00a88ad1b51e5d6c91e192386711e79a.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_40816.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_40816.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E5%AE%89%E8%A3%85Tesseract-OCR.exe&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;安装Tesseract-OCR.exe&lt;/h2&gt;&lt;h3 id=&quot;%E4%B8%8B%E8%BD%BD%E5%9C%B0%E5%9D%80&quot; style=&quot;margin: 10px 0px; padding: 0px; font-size: 16px; line-height: 1.5; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;下载地址&lt;/h3&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; line-height: 1.8; text-decoration-line: underline;&quot;&gt;http://8rr.co/Krrw&lt;/span&gt;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;12&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F3ca971effe71c77c64daaf7a9415bfc1.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_47469.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_47469.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;双击exe程序直接安装即可&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;11&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2Fc910363ee31c307bafd98c149986b124.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_75345.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_75345.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E9%85%8D%E7%BD%AE%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;配置环境变量&lt;/h2&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;10&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2Fd61737502914a0919920ddb8090ab8e7.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_89092.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083751_89092.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;9&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F037b401549294e5dc4240d4f926b3eb7.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083752_95250.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083752_95250.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E6%A0%A1%E9%AA%8C%E5%AE%89%E8%A3%85%E6%88%90%E5%8A%9F&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;校验安装成功&lt;/h2&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;8&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2Fcbe2048ef2325f2fad8b3138fae8c9b4.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083752_94885.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083752_94885.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E5%AE%89%E8%A3%85Pillow%E5%8C%85&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;安装Pillow包&lt;/strong&gt;&lt;/h2&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Python自带的图文简单处理模块，正常安装Python的时候会自动安装，故无需另外手动安装。（若没自动安装则可手动安装：pip install Pillow）&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h1 id=&quot;%E4%BB%A3%E7%A0%81%E6%AD%A3%E6%96%87&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 28px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;代码正文&lt;/h1&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E5%88%9D%E5%A7%8B%E5%8C%96%E6%B5%8F%E8%A7%88%E5%99%A8%E5%92%8C%E5%85%83%E7%B4%A0%E5%AE%9A%E4%BD%8D%E6%96%B9%E5%BC%8F&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;初始化浏览器和元素定位方式&lt;/h2&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;初始化并放大浏览器初始化元素定位方式：本文使用CSS选择器方式定位&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;7&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2Fb6e3716a219da876555ffcbb347b3680.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083752_71718.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083752_71718.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;6&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2Fefe23b322f34f461cfd8e93a86103803.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083753_93888.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083753_93888.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E8%8E%B7%E5%8F%96%E5%9B%BE%E7%89%87&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;获取图片&lt;/h2&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;页面全屏截图截图转为Image对象获取指定图片的大小和位置裁剪图片&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;5&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F54824b4eed53a1dc92a33feaefe922af.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083753_99238.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083753_99238.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;4&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F8d15cd9afdfbf3befd83af4121455236.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083753_85683.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083753_85683.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E8%AF%86%E5%88%AB%E5%9B%BE%E7%89%87%E4%B8%8A%E7%9A%84%E6%96%87%E6%9C%AC&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;识别图片上的文本&lt;/h2&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;识别裁剪后的图片上的文本内容&lt;/strong&gt;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;3&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F86da3d129c24aedb42122cc8b22c17f1.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_56207.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_56207.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;2&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F1fbca672c9ae9dbd20ce251b004cd67f.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_46433.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_46433.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h1 id=&quot;%E9%97%AE%E9%A2%98%EF%BC%9A&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 28px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;问题：&lt;/h1&gt;&lt;h2 id=&quot;Python%E8%84%9A%E6%9C%AC%E8%BF%90%E8%A1%8C%E6%8A%A5%E9%94%99%EF%BC%9A&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;Python脚本运行报错：&lt;/h2&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;1&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2F7ade91b211c33dbe97e5fc3fa24b3eb3.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_67447.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_67447.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;span class=&quot;cke_image_resizer&quot; title=&quot;点击并拖拽以改变尺寸&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;span class=&quot;cke_reset cke_widget_drag_handler_container&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083750_62299.gif&quot; width=&quot;15&quot; height=&quot;15&quot; class=&quot;cke_reset cke_widget_drag_handler&quot; title=&quot;点击并拖拽以移动&quot; data-cke-widget-drag-handler=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;h2 id=&quot;%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%EF%BC%9A&quot; style=&quot;margin: 10px 0px; padding: 0px; line-height: 1.5; font-size: 21px; font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;解决方案：&lt;/h2&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;修改tesseract文件的默认路径&lt;/p&gt;&lt;div class=&quot;cke_widget_wrapper cke_widget_block cke_widget_image cke_image_nocaption cke_widget_selected&quot; data-cke-display-name=&quot;图像&quot; data-cke-filter=&quot;off&quot; data-cke-widget-id=&quot;0&quot; data-cke-widget-wrapper=&quot;1&quot; style=&quot;margin: 0px; padding: 0px; color: rgb(51, 51, 51); font-family: verdana, Arial, Helvetica, sans-serif; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;p class=&quot;cke_widget_element&quot; data-cke-widget-data=&quot;%7B%22hasCaption%22%3Afalse%2C%22src%22%3A%22https%3A%2F%2Fimg-blog.csdnimg.cn%2Fimg_convert%2Fde10af8c69f0b98bcf59bdd83fe7b104.png%22%2C%22alt%22%3A%22%E5%B7%A7%E7%94%A8Python%E8%84%9A%E6%9C%AC%E8%A7%A3%E5%86%B3%E8%87%AA%E5%8A%A8%E5%8C%96%E5%9B%BE%E5%BD%A2%E9%AA%8C%E8%AF%81%E7%A0%81%E9%9A%BE%E9%A2%98%22%2C%22width%22%3A%22%22%2C%22height%22%3A%22%22%2C%22lock%22%3Atrue%2C%22align%22%3A%22center%22%2C%22classes%22%3Anull%7D&quot; data-cke-widget-keep-attr=&quot;0&quot; data-cke-widget-upcasted=&quot;1&quot; data-widget=&quot;image&quot; style=&quot;margin: 10px auto; padding: 0px;&quot;&gt;&lt;span class=&quot;cke_image_resizer_wrapper&quot; style=&quot;margin: 0px; padding: 0px; line-height: 1.8;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_24697.png&quot; alt=&quot;巧用Python脚本解决自动化图形验证码难题&quot; data-cke-saved-src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083754_24697.png&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: none; max-width: 100%; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;/div&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 19 Nov 2021 08:37:17 +0800</pubDate></item><item><title>Python生成遍历暴力破解密码</title><link>http://xpxw.com/?id=164</link><description>&lt;p&gt;&lt;span style=&quot;color: #333333; font-family: verdana, Arial, Helvetica, sans-serif; background-color: #FFFFFF;&quot;&gt;是暴力破解，是把所有的密码进行的遍历，也就是从1到。。。。无穷的列举出来&lt;/span&gt;&lt;/p&gt;&lt;p&gt;import itertools as its&amp;nbsp; &amp;nbsp; &amp;nbsp;##这个库，python自带的&lt;/p&gt;&lt;p&gt;import rarfile&amp;nbsp; &amp;nbsp;#这个是操作rar压缩包的，如果你需要破解别的密码的话，比如pdf，那么请你安装下pdf的第三方库&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;### 这个根据需要来，这边测试的是破解rar压缩包&lt;/p&gt;&lt;p&gt;path1 = &amp;quot;E:\\python2\\rar\\1.rar&amp;quot;&amp;nbsp; # 需要解压的文件路径及地址&lt;/p&gt;&lt;p&gt;path2 = &amp;quot;E:\\python2\\rar&amp;quot;&amp;nbsp; # 需要解压到的文件夹地址&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;##下面的是你的密码可能用的字符#&lt;/p&gt;&lt;p&gt;words = &amp;quot;1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!#$%&amp;amp;&amp;#39;( )*+,-./:;&amp;lt;=&amp;gt;?@[]^_`{|}~&amp;quot;&amp;nbsp; &amp;nbsp; ##密码里面含有大小写字母，数字以及特殊符号&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;re=4&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ##这个是与下面的repeat相对应的，代表你需要生成几位的数组。这里是4，代表生成4位的数组。&lt;/p&gt;&lt;p&gt;while 2&amp;gt;1:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; r = its.product(words,repeat=re)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; for i in r:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # print(type(i))&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; a =&amp;quot;&amp;quot;.join(i)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ##通过.join将数组里面的元素转换成字符串&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;quot;当前测试密码:&amp;quot;,a)&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ###尝试测试密码，如果错误continue，进入下一次循环&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rf = rarfile.RarFile(path1)&amp;nbsp; # pwd为解压密码&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rf.extractall(path=path2, pwd=a)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;密码破解成功:&amp;#39;,a)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit(0)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; except Exception as e:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(e)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; continue&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; else:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; re+=1&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;###如果将所有的4位字符组合尝试完成后，还是没有破解到密码，那么会将4再加上1，进行5位数的破解（这里没有具体写出，为了代码的整洁，没有写出如何循环到5位数密码）&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 19 Nov 2021 08:36:16 +0800</pubDate></item><item><title>SCRAPY爬虫框架的使用</title><link>http://xpxw.com/?id=163</link><description>&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;对于初学者来说还是需要有一定的基础作为铺垫的学习。我将从下方的思维导图中进行逐步的解析讲述。&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;实验工具即环境：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;　　笔记本:Y9000X 2020&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;　　系统：win10&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;　　Python版本：python3.8.6&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;　　pycharm版本：pycharm 2021.1.2(Professional Edition)&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_86447.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 18px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;一、安装&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;下载tiwisted，此处位下载地址：http://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;下载好后打开终端进行安装scrapy的必要模块　　&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;安装tiwisted，pip install&amp;nbsp;tiwisted-xxxx&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;安装pywin32：pip install pywin32　&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;安装scrapy：pip install scrapy&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;安装完成后在终端输入scrapy如果没有报错即安装成功。&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_97762.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 18px;&quot;&gt;二&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;、创建scrapy的工程&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;在pycharm中创建好的项目中的中终端输入&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;margin: 5px 0px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; font-size: 12px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;; overflow-wrap: break-word;&quot;&gt;scrapy&amp;nbsp;startproject&amp;nbsp;SDFDQPRO&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_60231.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;检查下项目目录即可发现多出了如下的工程目录&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_51253.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 18px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;三、创建一个爬虫目录&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;在终端找到之前所创建的工程目录，在此目录下输入&lt;/strong&gt;scrapy genspider sdfdq_cj http://www.csrc.gov.cn/pub/shandong/&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;后方网站为中国证券监督管理委员会山东监管局。&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_52120.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px auto; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto; display: block;&quot;/&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;运行后可发现工程目录中多出一个名为sdfdq_cj.py的爬虫文件。&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_13113.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px auto; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto; display: block;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;进入到爬虫文件中可以看到如下代码&lt;/p&gt;&lt;p&gt;import scrapy&lt;/p&gt;&lt;p&gt;class SdfdqCjSpider(scrapy.Spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; name = &amp;#39;sdfdq_cj&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 表示被允许的url&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # allowed_domains = [&amp;#39;http://www.csrc.gov.cn/pub/shandong/&amp;#39;]&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 起始url列表:该列表中存放的url会被scrapy自动进行请求的发送&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; start_urls = [&amp;#39;http://www.csrc.gov.cn/pub/shandong/sdfdqyxx/&amp;#39;]&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 用作于数据解析：response参数表示的就是请求成功后对应的响应对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def parse(self, response):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pass&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;接下来对网站解析选取需要获取的内容&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 18px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;四、数据解析&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_63604.png&quot; alt=&quot;&quot; width=&quot;682&quot; height=&quot;601&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px auto; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto; display: block;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;通过对网站的查看可以看出我们需要的是辅导期中的企业基本情况、工作进展报告、工作总结总的标题，日期以及链接。&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;scrapy对网站的解析沿用了xpath的解析方式。&lt;/p&gt;&lt;p&gt;import scrapy&lt;/p&gt;&lt;p&gt;class SdfdqCjSpider(scrapy.Spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; name = &amp;#39;sdfdq_cj&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 表示被允许的url&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # allowed_domains = [&amp;#39;http://www.csrc.gov.cn/pub/shandong/&amp;#39;]&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 起始url列表:该列表中存放的url会被scrapy自动进行请求的发送&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; start_urls = [&amp;#39;http://www.csrc.gov.cn/pub/shandong/sdfdqyxx/&amp;#39;]&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 用作于数据解析：response参数表示的就是请求成功后对应的响应对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def parse(self, response):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; li_list = response.xpath(&amp;#39;//div[@class=&amp;quot;zi_er_right&amp;quot;]//div[@class=&amp;quot;fl_list&amp;quot;]//li&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for li in li_list:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # xpath返回的是列表，但是列元素一定是Selector类型的对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # extract可以将Selector对象中的data参数存储的字符串提取出来&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 列表调用了extract之后则表示将列表中每一个data参数存储的字符串提取出来&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; title = li.xpath(&amp;#39;./a//text()&amp;#39;)[0].extract()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date = li.xpath(&amp;#39;./span/text()&amp;#39;)[0].extract()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url = &amp;#39;http://www.csrc.gov.cn/pub/shandong/sdfdqyxx&amp;#39;+li.xpath(&amp;#39;./a/@href&amp;#39;).extract_first()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;title&amp;#39;,title)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;url&amp;#39;,url)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;date&amp;#39;,date)&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;对网站的内容解析后运行scrapy&amp;nbsp; 终端输入&amp;nbsp;&lt;span style=&quot;margin: 0px; padding: 0px; color: #00FF00;&quot;&gt;scrapy crawl&amp;nbsp;sdfdq_cj&amp;nbsp;&lt;/span&gt;&amp;nbsp;注意：此语句的运行目录&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_87579.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px auto; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto; display: block;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;可以看到我们想获取的内容：&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;内容获取到我们必须要将其持久化存储才有意义：&lt;br style=&quot;margin: 0px; padding: 0px;&quot;/&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 18px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;五、scrapy的持久化存储&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;1）基于指令的持久化存储：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;要求：只可以将parse的方法返回值存储到本地的文本文件中&lt;/p&gt;&lt;p&gt;def parse(self, response):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 创建一个列表接收获取的数据&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; all_data = []&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; li_list = response.xpath(&amp;#39;//div[@class=&amp;quot;zi_er_right&amp;quot;]//div[@class=&amp;quot;fl_list&amp;quot;]//li&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for li in li_list:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # xpath返回的是列表，但是列元素一定是Selector类型的对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # extract可以将Selector对象中的data参数存储的字符串提取出来&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 列表调用了extract之后则表示将列表中每一个data参数存储的字符串提取出来&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; title = li.xpath(&amp;#39;./a//text()&amp;#39;)[0].extract()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date = li.xpath(&amp;#39;./span/text()&amp;#39;)[0].extract()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url = &amp;#39;http://www.csrc.gov.cn/pub/shandong/sdfdqyxx&amp;#39;+li.xpath(&amp;#39;./a/@href&amp;#39;).extract_first()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 基于终端指令的持久化存储操作&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dic = {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;title&amp;#39;:title,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;url&amp;#39;:url,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;date&amp;#39;:date&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; all_data.append(dic)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return all_data&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;接下来在终端中输入&amp;nbsp;scrapy crawl sdfdq_cj -o ./sdfdq.csv&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;将获取的文本内容存储到对应路径下的sdfdq.csv文本文件中&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_67779.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px auto; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto; display: block;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255); text-align: center;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 18pt;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;-----第二更&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;-----&lt;/strong&gt;&lt;/strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;补充下知识点 在进行scrapy时需要对配置文件&lt;span style=&quot;margin: 0px; padding: 0px; color: #FF0000;&quot;&gt;settings&lt;/span&gt;的权限进行一定的修改：&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_40243.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/p&gt;&lt;p&gt;BOT_NAME = &amp;#39;SDFDQPRO&amp;#39;&lt;/p&gt;&lt;p&gt;# 日志输出&lt;/p&gt;&lt;p&gt;LOG_LEVEL = &amp;#39;ERROR&amp;#39;&lt;/p&gt;&lt;p&gt;SPIDER_MODULES = [&amp;#39;SDFDQPRO.spiders&amp;#39;]&lt;/p&gt;&lt;p&gt;NEWSPIDER_MODULE = &amp;#39;SDFDQPRO.spiders&amp;#39;&lt;/p&gt;&lt;p&gt;# UA伪装&lt;/p&gt;&lt;p&gt;USER_AGENT =&amp;#39;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36 Edg/92.0.902.73&amp;#39;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;# Crawl responsibly by identifying yourself (and your website) on the user-agent&lt;/p&gt;&lt;p&gt;#USER_AGENT = &amp;#39;SDFDQPRO (+http://www.yourdomain.com)&amp;#39;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;# Obey robots.txt rules&lt;/p&gt;&lt;p&gt;# ROBOTSTXT_OBEY协议 此条分享严格遵守此协议/可根据个人的需求将True 改为FALSE&lt;/p&gt;&lt;p&gt;ROBOTSTXT_OBEY = True&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;2）基于管道的持久化存储&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083534_27075.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px auto; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto; display: block;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;数据解析的步骤昨天已经分享好了接下来按照上方流程图来进行基于管道的存储方式&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;一、在Item中定义相关属性：&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083535_19676.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;在项目目录下打来items文件进行配置&lt;/p&gt;&lt;p&gt;import scrapy&lt;/p&gt;&lt;p&gt;class SdfdqproItem(scrapy.Item):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # define the fields for your item here like:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; title = scrapy.Field()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; url = scrapy.Field()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; date = scrapy.Field()&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;二、将数据封存到item类型对象中&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;将数据封存到item类型对象中我们需要在爬虫文件中引用到配置好的items文件中的类的方法SdfdqprItem&lt;/p&gt;&lt;p&gt;#应用item中的方法&lt;/p&gt;&lt;p&gt;from SDFDQPRO.items import SdfdqproItem&lt;/p&gt;&lt;p&gt;#将解析后数据封装到Item中&lt;/p&gt;&lt;p&gt;item[&amp;#39;title&amp;#39;] = title&lt;/p&gt;&lt;p&gt;item[&amp;#39;url&amp;#39;] = url&lt;/p&gt;&lt;p&gt;item[&amp;#39;date&amp;#39;] = date&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;三、Item类型的对象提交给管道进行持久化存储：&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;margin: 5px 0px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; font-size: 12px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;; overflow-wrap: break-word;&quot;&gt;yield&amp;nbsp;item&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;四、在管道接收Item数据进行存储&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083535_55910.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;在pipelines.py文件中进行管道接收Item的操作，&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;因为我们获取数据的方式基于管道所以没传输一次管道都会运行一次，故需要自己写两个方法（open_spider,close_spider）在里面&lt;/p&gt;&lt;p&gt;class SdfdqproPipeline:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; fp = None&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 开始只会被调用一次&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def open_spider(self,spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;spider_start&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.fp=open(&amp;#39;fdq.txt&amp;#39;,&amp;#39;w&amp;#39;,encoding=&amp;#39;utf-8&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 用来处理Item类型对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 此方法可接收爬虫文件提交过来的Item对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 没接收一次item就会被调用一次&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def process_item(self, item, spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; title = item[&amp;#39;title&amp;#39;]&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url = item[&amp;#39;url&amp;#39;]&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date = item[&amp;#39;date&amp;#39;]&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.fp.write(title+&amp;#39;,&amp;#39;+url+&amp;#39;,&amp;#39;+date+&amp;#39;\n&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return item&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 结束只会被调用一次&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def close_spider(self,spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.fp.close()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;spider_end&amp;#39;)&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;五、开启管道&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;在配置文件中找到下方的代码取消注释即可开启管道&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;margin: 5px 0px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; font-size: 12px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;; overflow-wrap: break-word;&quot;&gt;ITEM_PIPELINES&amp;nbsp;=&amp;nbsp;{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;#39;SDFDQPRO.pipelines.SdfdqproPipeline&amp;#39;:&amp;nbsp;300,#&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;数值表示优先级&amp;nbsp;越小优先级越大}&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;截止至2021.11.10爬虫文件的全部代码在下面啦！！&lt;/p&gt;&lt;p&gt;import scrapy&lt;/p&gt;&lt;p&gt;from SDFDQPRO.items import SdfdqproItem&lt;/p&gt;&lt;p&gt;class SdfdqCjSpider(scrapy.Spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; name = &amp;#39;sdfdq_cj&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 表示被允许的url&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # allowed_domains = [&amp;#39;http://www.csrc.gov.cn/pub/shandong/&amp;#39;]&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 起始url列表:该列表中存放的url会被scrapy自动进行请求的发送&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; start_urls = [&amp;#39;http://www.csrc.gov.cn/pub/shandong/sdfdqyxx/&amp;#39;]&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; # 用作于数据解析：response参数表示的就是请求成功后对应的响应对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def parse(self, response):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 创建一个列表接收获取的数据&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; all_data = []&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; li_list = response.xpath(&amp;#39;//div[@class=&amp;quot;zi_er_right&amp;quot;]//div[@class=&amp;quot;fl_list&amp;quot;]//li&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for li in li_list:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # xpath返回的是列表，但是列元素一定是Selector类型的对象&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # extract可以将Selector对象中的data参数存储的字符串提取出来&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 列表调用了extract之后则表示将列表中每一个data参数存储的字符串提取出来&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; title = li.xpath(&amp;#39;./a//text()&amp;#39;)[0].extract()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; date = li.xpath(&amp;#39;./span/text()&amp;#39;)[0].extract()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; url = &amp;#39;http://www.csrc.gov.cn/pub/shandong/sdfdqyxx&amp;#39;+li.xpath(&amp;#39;./a/@href&amp;#39;).extract_first()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 基于终端指令的持久化存储操作&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dic = {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;title&amp;#39;:title,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;url&amp;#39;:url,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;date&amp;#39;:date&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; all_data.append(dic)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 封装管道&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; item = SdfdqproItem()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; item[&amp;#39;title&amp;#39;] = title&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; item[&amp;#39;url&amp;#39;] = url&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; item[&amp;#39;date&amp;#39;] = date&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 将item提交给管道&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; yield item&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255); text-align: center;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 18pt;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;--------第三更&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;--------&lt;/strong&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255); text-align: center;&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; font-size: 15px;&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;基于管道将数据存储到数据库&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;python链接数据库的方法：&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;安装：pymsql pip install pymysql&lt;/strong&gt;&lt;span style=&quot;margin: 0px; padding: 0px; background-color: #2B2B2B; color: #A9B7C6; font-family: &amp;quot;JetBrains Mono&amp;quot;, monospace; font-size: 9.8pt;&quot;&gt;&lt;br style=&quot;margin: 0px; padding: 0px;&quot;/&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;一、新建一个数据库来存储即将接收的数据&lt;/strong&gt;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;span style=&quot;margin: 0px; padding: 0px; color: #FF0000;&quot;&gt;注意&lt;/span&gt;：&lt;/strong&gt;在表中需要和我们获取的数据的字段保持一致&lt;/p&gt;&lt;div class=&quot;cnblogs_code&quot; style=&quot;margin: 5px 0px; padding: 5px; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); overflow: auto; font-size: 12px; white-space: normal; font-family: &amp;quot;Courier New&amp;quot; !important;&quot;&gt;&lt;pre style=&quot;margin-top: 0px; margin-bottom: 0px; padding: 0px; overflow: auto; font-family: &amp;quot;Courier New&amp;quot;; overflow-wrap: break-word;&quot;&gt;CREATE&amp;nbsp;TABLE&amp;nbsp;`fdq`&amp;nbsp;(
&amp;nbsp;&amp;nbsp;`title`&amp;nbsp;varchar(255)&amp;nbsp;CHARACTER&amp;nbsp;SET&amp;nbsp;utf8&amp;nbsp;COLLATE&amp;nbsp;utf8_bin&amp;nbsp;NOT&amp;nbsp;NULL,
&amp;nbsp;&amp;nbsp;`url`&amp;nbsp;varchar(255)&amp;nbsp;COLLATE&amp;nbsp;utf8_bin&amp;nbsp;DEFAULT&amp;nbsp;NULL,
&amp;nbsp;&amp;nbsp;`date`&amp;nbsp;datetime&amp;nbsp;DEFAULT&amp;nbsp;NULL)&amp;nbsp;ENGINE=InnoDB&amp;nbsp;DEFAULT&amp;nbsp;CHARSET=utf8mb3&amp;nbsp;COLLATE=utf8_bin&lt;/pre&gt;&lt;/div&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&amp;nbsp;&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;在piplines.py中设置数据库的连接和存储操作&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;import pymysql&lt;/p&gt;&lt;p&gt;class SdfdqproPipeline(object):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; conn = None&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; cursor = None&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def open_spider(self,spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;write_start&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 设置数据库接口&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.conn = pymysql.Connect(host=&amp;#39;127.0.0.1&amp;#39;, port=3306, user=&amp;#39;root&amp;#39;, password=&amp;#39;123&amp;#39;, db=&amp;#39;fdq&amp;#39;,charset=&amp;#39;utf8&amp;#39;)&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def process_item(self,item,spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 设置数据游标&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.cursor = self.conn.cursor()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.cursor.execute(&amp;#39;insert into fdq values(&amp;quot;%s&amp;quot;,&amp;quot;%s&amp;quot;,&amp;quot;%s&amp;quot;)&amp;#39;%(item[&amp;quot;title&amp;quot;],item[&amp;quot;url&amp;quot;],item[&amp;#39;date&amp;#39;]))&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.conn.commit()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 如果数据存储异常就回滚&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; except Exception as e:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(e)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.conn.rollback()&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return item&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; def close_spider(self,spider):&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; # 关闭数据库链接&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.conn.close()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; self.cursor.close()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print(&amp;#39;write_over&amp;#39;)&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;然后开始运行&amp;nbsp;&lt;/strong&gt;scrapy crawl sdfdq_cj j 完成后就可以在我们的数据库中看到获取后的数据了：&lt;/p&gt;&lt;p style=&quot;margin: 10px auto; padding: 0px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; white-space: normal; background-color: rgb(255, 255, 255);&quot;&gt;&lt;strong style=&quot;margin: 0px; padding: 0px;&quot;&gt;&lt;img src=&quot;http://xpxw.com/zb_users/upload/2021/11/20211119083535_35959.png&quot; alt=&quot;&quot; loading=&quot;lazy&quot; class=&quot;medium-zoom-image&quot; style=&quot;margin: 0px; padding: 0px; border: 0px; max-width: 660px; cursor: zoom-in; transition: transform 0.3s cubic-bezier(0.2, 0, 0.2, 1) 0s !important; height: auto;&quot;/&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 19 Nov 2021 08:32:51 +0800</pubDate></item><item><title>PHP通过jwt实现接口验证</title><link>http://xpxw.com/?id=162</link><description>&lt;p&gt;1、先定义controller控制器基类Base.php，作用是继承改类的，都需要进行token验证；&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;2、在定义一个前端api基类IndexBase.php，作为一个中间层，里面存放验证后token里面的用户信息&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;3、书写PHP实现jwt基类PhpJwt.php，改类主要是获取token，和验证token;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;上面三者的关系是，IndexBase.php继承Base.php继承PhpJwt.php。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;前端与后端验证逻辑如下：&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;1、前端请求接口，后台验证token;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;2、没有token，给出提示，前端输入账号密码（微信公众号类，直接通过非静默授权，获取用户openid）,进行验证用户信息。验证通过后，将用户uid加载到jwt载荷中，生成token。一个验证toekn（过期时间比较短），一个刷新token（过期时间较长，用于避免每次段时间内，用户重复登录）。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;3、前端通过登录拿到两个token后，存起来。然后在请求需要验证的接口时，在header头部加入参数authorization：用户toekn；来进行验证，后台通过token来解析出当前请求用户的信息。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;核心代码&lt;/p&gt;&lt;p&gt;　　　　1、PhpJwt.php&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;lt;?php&lt;/p&gt;&lt;p&gt;namespace lib;&lt;/p&gt;&lt;p&gt;class PhpJwt {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //头部&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $header = array(&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;alg&amp;#39;=&amp;gt;&amp;#39;HS256&amp;#39;, //生成signature的算法&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;typ&amp;#39;=&amp;gt;&amp;#39;JWT&amp;#39;&amp;nbsp; //类型&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; );&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //使用HMAC生成信息摘要时所使用的密钥 md5(&amp;#39;jjgw2021&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $key = &amp;#39;99dc2d62ab85bcd9185f3e9324db5567&amp;#39;;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //md5(&amp;#39;jjgw2021admin&amp;#39;)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $admin_key = &amp;#39;12d44e568140bf62d84d9cb3e20b1103&amp;#39;;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //请求jwt 过期时间 2小时（上线后改为10分钟）&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $request_expect = 3600;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //刷新jwt 过期时间 24小时&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $refresh_expect = 86400;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $admin_request_expect = 1800;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $admin_refresh_expect = 7200;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //判断是否后端token&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; private static $is_admin = &amp;#39;is_admin&amp;#39;;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /*** 获取jwt token&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param array $payload jwt载荷&amp;nbsp; 格式如下非必须&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* &amp;#39;iss&amp;#39;=&amp;gt;&amp;#39;jwt_admin&amp;#39;, //该JWT的签发者&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* &amp;#39;iat&amp;#39;=&amp;gt;time(), //签发时间&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* &amp;#39;exp&amp;#39;=&amp;gt;time()+7200, //过期时间&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* &amp;#39;nbf&amp;#39;=&amp;gt;time()+60, //该时间之前不接收处理该Token&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* &amp;#39;sub&amp;#39;=&amp;gt;&amp;#39;www.admin.com&amp;#39;, //面向的用户&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* &amp;#39;jti&amp;#39;=&amp;gt;md5(uniqid(&amp;#39;JWT&amp;#39;).time()) //该Token唯一标识&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* ]&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param int $refresh 是否刷新token 1是&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param int $is_admin 是否后台调用 1是 0 admin&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return string&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; public static function getToken(array $payload, $refresh = 0, $is_admin = 0)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $exp = $refresh ? ($is_admin ? self::$admin_refresh_expect : self::$refresh_expect) : ($is_admin ? self::$admin_request_expect : self::$request_expect);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $load = [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;iat&amp;#39; =&amp;gt; time(),&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;exp&amp;#39; =&amp;gt; time() + $exp,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;jti&amp;#39; =&amp;gt; md5(uniqid(&amp;#39;JWT&amp;#39;).time())&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $payload = array_merge($load, $payload);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $key = ($is_admin == 1 ? self::$admin_key : self::$key);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $base64header = self::base64UrlEncode(json_encode(self::$header,JSON_UNESCAPED_UNICODE));&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $base64payload = self::base64UrlEncode(json_encode($payload,JSON_UNESCAPED_UNICODE));&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $token = $base64header.&amp;#39;.&amp;#39;.$base64payload.&amp;#39;.&amp;#39;.self::signature($base64header.&amp;#39;.&amp;#39;.$base64payload,$key,self::$header[&amp;#39;alg&amp;#39;]);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return $token;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; /**&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* 验证token是否有效,默认验证exp,nbf,iat时间&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @param string $Token 需要验证的token&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @return array&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;*/&lt;/p&gt;&lt;p&gt;&amp;nbsp; public static function verifyToken($Token)&lt;/p&gt;&lt;p&gt;&amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $tokens = explode(&amp;#39;.&amp;#39;, $Token);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (count($tokens) != 3){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; 100,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;验证失败&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; list($base64header, $base64payload, $sign) = $tokens;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //获取jwt算法&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $base64decodeheader = json_decode(self::base64UrlDecode($base64header), JSON_OBJECT_AS_ARRAY);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (empty($base64decodeheader[&amp;#39;alg&amp;#39;])){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; 100,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;验证失败&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $payload = json_decode(self::base64UrlDecode($base64payload), JSON_OBJECT_AS_ARRAY);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $key = !empty($payload[self::$is_admin]) ? self::$admin_key : self::$key;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //签名验证&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (self::signature($base64header . &amp;#39;.&amp;#39; . $base64payload, $key, $base64decodeheader[&amp;#39;alg&amp;#39;]) !== $sign){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; 100,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;签名验证失败&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //签发时间大于当前服务器时间验证失败&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (isset($payload[&amp;#39;iat&amp;#39;]) &amp;amp;&amp;amp; $payload[&amp;#39;iat&amp;#39;] &amp;gt; time()) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; 100,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;签发时间大于当前服务器时间,验证失败&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //过期时间小宇当前服务器时间验证失败&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (isset($payload[&amp;#39;exp&amp;#39;]) &amp;amp;&amp;amp; $payload[&amp;#39;exp&amp;#39;] &amp;lt; time()) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; 200,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;已过期&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //该nbf时间之前不接收处理该Token&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (isset($payload[&amp;#39;nbf&amp;#39;]) &amp;amp;&amp;amp; $payload[&amp;#39;nbf&amp;#39;] &amp;gt; time()) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; 100,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;验证失败&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; 0,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;验证成功&amp;#39;,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;data&amp;#39; =&amp;gt;$payload&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; /**&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* base64UrlEncode&amp;nbsp; https://jwt.io/ 中base64UrlEncode编码实现&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @param string $input 需要编码的字符串&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @return string&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;*/&lt;/p&gt;&lt;p&gt;&amp;nbsp; private static function base64UrlEncode($input)&lt;/p&gt;&lt;p&gt;&amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return str_replace(&amp;#39;=&amp;#39;, &amp;#39;&amp;#39;, strtr(base64_encode($input), &amp;#39;+/&amp;#39;, &amp;#39;-_&amp;#39;));&lt;/p&gt;&lt;p&gt;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; /**&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* base64UrlEncode https://jwt.io/ 中base64UrlEncode解码实现&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @param string $input 需要解码的字符串&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @return bool|string&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;*/&lt;/p&gt;&lt;p&gt;&amp;nbsp; private static function base64UrlDecode($input)&lt;/p&gt;&lt;p&gt;&amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $remainder = strlen($input) % 4;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if ($remainder) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $addlen = 4 - $remainder;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $input .= str_repeat(&amp;#39;=&amp;#39;, $addlen);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return base64_decode(strtr($input, &amp;#39;-_&amp;#39;, &amp;#39;+/&amp;#39;));&lt;/p&gt;&lt;p&gt;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; /**&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* HMACSHA256签名&amp;nbsp; https://jwt.io/ 中HMACSHA256签名实现&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @param string $input 为base64UrlEncode(header).&amp;quot;.&amp;quot;.base64UrlEncode(payload)&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @param string $key&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @param string $alg&amp;nbsp; 算法方式&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;* @return mixed&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;*/&lt;/p&gt;&lt;p&gt;&amp;nbsp; private static function signature($input, $key, $alg )&lt;/p&gt;&lt;p&gt;&amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $alg_config = array(&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;HS256&amp;#39;=&amp;gt;&amp;#39;sha256&amp;#39;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; );&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; return self::base64UrlEncode(hash_hmac($alg_config[$alg], $input, $key,true));&lt;/p&gt;&lt;p&gt;&amp;nbsp; }&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;复制代码&lt;/p&gt;&lt;p&gt;　　　　2、Base.php&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;复制代码&lt;/p&gt;&lt;p&gt;&amp;lt;?php&lt;/p&gt;&lt;p&gt;/*&lt;/p&gt;&lt;p&gt;&amp;nbsp;* @Fun: 控制器基类&lt;/p&gt;&lt;p&gt;&amp;nbsp;* @User: JessieK&lt;/p&gt;&lt;p&gt;&amp;nbsp;* @Date: 2021-08-19 18:06:47&lt;/p&gt;&lt;p&gt;&amp;nbsp;*/&lt;/p&gt;&lt;p&gt;namespace app\controller;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;use app\BaseController;&lt;/p&gt;&lt;p&gt;use think\facade\Request;&lt;/p&gt;&lt;p&gt;use lib\PhpJwt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;class Base extends BaseController&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //会员uid&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; protected $uid;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //会员unionid&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; protected $unionid;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //会员openid&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; protected $openid;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //jwt&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; protected $payload;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; public function __construct()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //更新中&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // $this-&amp;gt;apiResult(-100, &amp;#39;网站正在火速更新中，请稍后---&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // $controller = strtolower(Request::controller());&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $action = strtolower(Request::action());&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!in_array($action, [&amp;#39;wechatlogin&amp;#39;, &amp;#39;index&amp;#39;, &amp;#39;coc&amp;#39;, &amp;#39;arealist&amp;#39;, &amp;#39;uploadimg&amp;#39;, &amp;#39;uploadimgstring&amp;#39;])){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //验证token&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;checkToken();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!in_array($action, [&amp;#39;wechatlogin&amp;#39;, &amp;#39;index&amp;#39;, &amp;#39;coc&amp;#39;, &amp;#39;arealist&amp;#39;, &amp;#39;uploadimg&amp;#39;, &amp;#39;getjwt&amp;#39;, &amp;#39;uploadimgstring&amp;#39;])){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //验证sign&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // $this-&amp;gt;verifySign();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /**&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* 验证token&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; public function checkToken()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $token = empty(Request::header()[&amp;#39;authorization&amp;#39;]) ? &amp;#39;&amp;#39; : Request::header()[&amp;#39;authorization&amp;#39;];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!$token){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(-100, &amp;#39;Authorization不能为空&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $get_payload = PhpJwt::verifyToken($token);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; switch($get_payload[&amp;#39;code&amp;#39;]){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; case 100:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(-100, &amp;#39;token验证失败&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; break;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; case 200:&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(1000, &amp;#39;token已过期&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;uid = $get_payload[&amp;#39;data&amp;#39;][&amp;#39;uid&amp;#39;];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;unionid = $get_payload[&amp;#39;data&amp;#39;][&amp;#39;unionid&amp;#39;];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;openid = $get_payload[&amp;#39;data&amp;#39;][&amp;#39;openid&amp;#39;];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;payload = $get_payload[&amp;#39;data&amp;#39;];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; /**&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* @name: 验证签名&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* @param {*}&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;* @return {*}&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;*/&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; public function verifySign()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $token = Request::header()[&amp;#39;authorization&amp;#39;];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; list($base64header, $base64payload, $jwtsign) = explode(&amp;#39;.&amp;#39;, $token);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $params = Request::post();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(empty($params[&amp;#39;sign&amp;#39;])){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(-100 ,&amp;#39;sign不能为空&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(empty($params[&amp;#39;timestamp&amp;#39;])){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(-100, &amp;#39;timestamp不能为空&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //10分钟有效 毫秒级&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (time() * 1000 - $params[&amp;#39;timestamp&amp;#39;] &amp;gt; 600000) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // $this-&amp;gt;apiResult(-100, &amp;#39;请求过期&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $request_sign = $params[&amp;#39;sign&amp;#39;];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //对关联数组按照键名进行升序排序&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; unset($params[&amp;#39;sign&amp;#39;]);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ksort($params);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $param_str = &amp;#39;&amp;#39;;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; foreach ($params as $k =&amp;gt; $v) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $v = is_array($v) ? json_encode($v, JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE) : $v;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $param_str .= $k.$v;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $restr = $param_str.$jwtsign;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $sign = md5($restr);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (strtolower($request_sign) != strtolower($sign)) {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(-100, &amp;#39;签名验证失败&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; public function apiResult($code, $msg, $data = [])&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $result = [&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;code&amp;#39; =&amp;gt; $code,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;msg&amp;#39; =&amp;gt; $msg,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;#39;data&amp;#39; =&amp;gt; $data,&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ];&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit(json_encode($result, JSON_UNESCAPED_UNICODE));&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;　　　　3、IndexBase.php&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;lt;?php&lt;/p&gt;&lt;p&gt;/*&lt;/p&gt;&lt;p&gt;&amp;nbsp;* @Fun: 前台api基类&lt;/p&gt;&lt;p&gt;namespace app\controller;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;use app\model\Member;&lt;/p&gt;&lt;p&gt;use think\facade\Request;&lt;/p&gt;&lt;p&gt;class IndexBase extends Base&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; //会员信息&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; protected $member_info;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; public function __construct()&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; {&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; parent::__construct();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!$this-&amp;gt;openid){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(-100, &amp;#39;缺少参数&amp;#39;, [&amp;#39;msg&amp;#39; =&amp;gt; &amp;#39;openid为空&amp;#39;]);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $memberModel = new Member();&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $member_info = $memberModel-&amp;gt;getUserInfoGather($this-&amp;gt;openid);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(!$member_info){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;apiResult(1001, &amp;#39;会员信息不存在&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //锁粉操作&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $from_uid = Request::get(&amp;#39;from_uid&amp;#39;);&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(empty($member_info[&amp;#39;from_uid&amp;#39;]) &amp;amp;&amp;amp; !empty($from_uid)){&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $memberModel-&amp;gt;setFromUid($member_info[&amp;#39;uid&amp;#39;], $from_uid, Request::url(true));&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // addlog(&amp;#39;errorlog/request/&amp;#39;, &amp;#39;pro&amp;#39;, &amp;#39;请求url=&amp;#39;.json_encode(request()-&amp;gt;get(), JSON_UNESCAPED_UNICODE));&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; $this-&amp;gt;member_info = $member_info;&lt;/p&gt;&lt;p&gt;&amp;nbsp; &amp;nbsp; }&lt;/p&gt;&lt;p&gt;}&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;最后书写业务代码&lt;/p&gt;&lt;p&gt;　　　　1、对于需要验证token的，只需要继承IndexBase.php即可，基类里面直接对前端传过来的token进行验证是否合法。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;　　　　2、用户在登录后，获取到请求token，进行接口验证；请求token过期后，不用重新登录，用户用刷新token刷新，获取到新的请求token，既可以重新获取验证，拿到用户信息，避免频繁登录。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;　　　　3、上述代码，还附带verfySign签名，这个主要是可以配合token进行一起使用。jwt实现验证用户身份，签名实现接口请求是否合法。大致逻辑，在每次请求接口时带上签名和时间戳，具体签名逻辑可看上述代码。&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 19 Nov 2021 08:31:12 +0800</pubDate></item></channel></rss>