{"id":42582,"date":"2020-02-25T09:31:59","date_gmt":"2020-02-25T01:31:59","guid":{"rendered":"http:\/\/4563.org\/?p=42582"},"modified":"2020-02-25T09:31:59","modified_gmt":"2020-02-25T01:31:59","slug":"virmach-%e7%ad%9b%e9%80%89%e8%84%9a%e6%9c%ac-python%e7%89%88","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=42582","title":{"rendered":"virmach \u7b5b\u9009\u811a\u672c python\u7248"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>beng<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:55:40\t<\/p>\n<h3>virmach \u7b5b\u9009\u811a\u672c python\u7248<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 beng \u4e8e 2019-11-29 17:06 \u7f16\u8f91 <\/p>\n<p> \u529f\u80fd\uff1a<br \/>  1.\u6309\u4e2a\u4eba\u8981\u6c42\u7b5b\u9009\u5339\u914d\u6761\u4ef6[\u4fee\u6539settings\u5373\u53ef]<br \/>  2.\u58f0\u97f3\u63d0\u9192\u529f\u80fd<br \/>  3.\u81ea\u52a8\u751f\u6210\u8d2d\u7269\u8f66\u94fe\u63a5<br \/>  4.\u65e0\u7b2c\u4e09\u65b9\u5e93\uff0c\u662fpython\u5c31\u80fd\u8dd1<\/p>\n<p>  \u7b49\u7b49\u518d\u5199\u4e2aSelenium+chrome\u7684\u811a\u672c \u5168\u81ea\u52a8<\/p>\n<p>  import requests<br \/>  import json<br \/>  import re<br \/>  import time<br \/>  import sys<br \/>  import winsound<br \/>  settings = {<br \/>  &nbsp; &nbsp; &#8216;price&#8217;: 15,<br \/>  &nbsp; &nbsp; &#8216;virt&#8217;: &#8216;KVM&#8217;,<br \/>  &nbsp; &nbsp; &#8216;ram&#8217;: 2048,<br \/>  &nbsp; &nbsp; &#8216;cpu&#8217;: 2,<br \/>  &nbsp; &nbsp; &#8216;hdd&#8217;: 30,<br \/>  &nbsp; &nbsp; &#8216;bw&#8217;: 1500,<br \/>  &nbsp; &nbsp; &#8216;ips&#8217;: 1,<br \/>  }<br \/>  url = &#8216;https:\/\/billing.virmach.com\/modules\/addons\/blackfriday\/new_plan.json&#8217;<\/p>\n<p>  def run():<br \/>  &nbsp; &nbsp; response = json.loads(requests.get(url).text)<br \/>  &nbsp; &nbsp; price = response[&#8216;price&#8217;]<br \/>  &nbsp; &nbsp; if &#8216;yr&#8217; in price:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;price = float(re.findall(&#8216;$(.+?) &lt;span&gt;\/yr&lt;\/span&gt;&#8217;, price))<br \/>  &nbsp; &nbsp; virt = response[&#8216;virt&#8217;]<br \/>  &nbsp; &nbsp; ram = int(response[&#8216;ram&#8217;])<br \/>  &nbsp; &nbsp; cpu = int(response[&#8216;cpu&#8217;])<br \/>  &nbsp; &nbsp; hdd = int(response[&#8216;hdd&#8217;])<br \/>  &nbsp; &nbsp; bw = int(response[&#8216;bw&#8217;])<br \/>  &nbsp; &nbsp; ips = int(response[&#8216;ips&#8217;])<br \/>  &nbsp; &nbsp; pid = response[&#8216;pid&#8217;]<br \/>  &nbsp; &nbsp; location = response[&#8216;location&#8217;]# BUFFALO<br \/>  &nbsp; &nbsp; if price &lt;= settings[&#8216;price&#8217;] and virt == settings[&#8216;virt&#8217;] and ram &gt;= settings[&#8216;ram&#8217;] and cpu &gt;= settings[<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&#8216;cpu&#8217;] and hdd &gt;= settings[&#8216;hdd&#8217;] and bw &gt;= settings[&#8216;bw&#8217;] and ips &gt;= settings[&#8216;ips&#8217;]:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;winsound.Beep(500, 1000)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(price)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(cpu, &#8216;H&#8217;, ram, &#8216;M&#8217;, bw, &#8216;G&#8217;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(&#8216;hdd:&#8217;, hdd, &#8216;G&#8217;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;if ips &gt; 1:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;print(ips)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(location)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;print(&#8216;https:\/\/billing.virmach.com\/cart.php?a=add&amp;pid=&#8217; + str(pid))<br \/>  &nbsp; &nbsp; else:<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;item = &#8216;\u65e0\u7b26\u5408\u673a\u5668 &#8216; + time.strftime(&quot;%H:%M:%S %Y-%m-%d&quot;, time.localtime())<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;sys.stdout.write(&#8216;r&#8217; + str(item) + &#8216;\u000033[K&#8217;)<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;sys.stdout.flush()<\/p>\n<p>  while 1:<br \/>  &nbsp; &nbsp; run()<br \/>  &nbsp; &nbsp; time.sleep(5)  \t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>hotkk<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:56:13\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5927\u4f6c\u725b\u903c\uff0c\u652f\u6301\u4e86\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u6587\u5c06<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:56:59\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5927\u4f6c\uff0c\u80fd\u5426\u52a0\u4e0a\u673a\u623f\u4f4d\u7f6e\u7684\u7b5b\u9009\u5462\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u9646\u4f2f\u8a00<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:57:21\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u662f\u5fc5\u987b\u8981\u5b8c\u5168\u4e00\u81f4\u624d\u4f1a\u63d0\u9192\u8fd8\u662f\u4f4e\u4e8e\u5c31\u53ef\u4ee5\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>beng<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:58:00\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u9646\u4f2f\u8a00 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:57<br \/>  \u662f\u5fc5\u987b\u8981\u5b8c\u5168\u4e00\u81f4\u624d\u4f1a\u63d0\u9192\u8fd8\u662f\u4f4e\u4e8e\u5c31\u53ef\u4ee5<\/p>\n<p> \u914d\u7f6e\u9ad8\u4e8e\u6216\u7b49\u4e8e\u5c31\u884c\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>tonyma<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:59:06\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u9646\u4f2f\u8a00 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 16:57<br \/>  \u662f\u5fc5\u987b\u8981\u5b8c\u5168\u4e00\u81f4\u624d\u4f1a\u63d0\u9192\u8fd8\u662f\u4f4e\u4e8e\u5c31\u53ef\u4ee5<\/p>\n<p> \u770b\u4ee3\u7801\uff0c\u5c31\u662f\u5927\u4e8e\u7684\u65f6\u5019\uff0c\u5f88\u7b80\u5355\uff0c\u968f\u4fbf\u81ea\u5b9a\u4e49\u5440\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>pangyuxing<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 17:00:38\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5927\u4f6c\uff0c\u7b2c35\u884c\u6f0f\u4e86\u4e00\u4e2a &#8216;\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>taian<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 17:00:44\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u652f\u6301\uff01\u8c22\u8c22\u5206\u4eab\u3002\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>fenghuang<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 17:01:19\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u8fd9\u4e2a\u4e0d\u9519 \u53ef\u4ee5\u6bd4\u8f83\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>qq272810532<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019-11-29 17:01:43\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u5927\u4f6c\uff0c\u8fd0\u884c\u63d0\u793a\u6ca1\u6709requests\u8fd9\u4e2a\u6a21\u5757\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>beng \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2019&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/42582"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=42582"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/42582\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=42582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=42582"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=42582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}