{"id":81,"date":"2020-12-19T15:08:48","date_gmt":"2020-12-19T07:08:48","guid":{"rendered":"https:\/\/www.one-year.cn\/?p=81"},"modified":"2021-01-31T10:52:12","modified_gmt":"2021-01-31T02:52:12","slug":"%e5%9f%ba%e4%ba%8epython%e7%9a%84%e5%86%85%e8%92%99%e5%8f%a4%e5%a4%a7%e5%ad%a6%e6%a0%a1%e5%9b%ad%e7%bd%91%e7%9a%84%e8%ae%a4%e8%af%81%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/www.constantinefun.com\/?p=81","title":{"rendered":"\u57fa\u4e8epython\u7684\u5185\u8499\u53e4\u5927\u5b66\u6821\u56ed\u7f51\u7684\u8ba4\u8bc1\u811a\u672c"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u8a00<\/h2>\n\n\n\n<p>        \u5185\u8499\u53e4\u5927\u5b66\u6821\u56ed\u7f51\u7cfb\u6df1\u6f9c\u8f6f\u4ef6\u7684\u7f51\u9875\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u6bcf\u4e2a\u8d26\u53f7\u6700\u591a\u540c\u65f6\u67093\u53f0\u8bbe\u5907\u4e0a\u7f51\uff0c\u7531\u4e8e\u79cd\u79cd\u539f\u56e0\u8ba4\u8bc1\u7f51\u9875\u65f6\u5e38\u65e0\u6cd5\u6253\u5f00\uff0c\u56e0\u6b64\u60f3\u5230\u7528\u811a\u672c\u6765\u6a21\u62df\u4eba\u5de5\u9a8c\u8bc1\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9e\u73b0<\/h2>\n\n\n\n<p>        python\u5177\u6709\u5f3a\u5927\u7684\u7b2c\u4e09\u65b9\u5e93\u65e2\u7136\u8981\u83b7\u53d6\u7f51\u9875\u4fe1\u606f\uff0c\u5fc5\u7136\u9009\u7528requests\u8fd9\u4e00\u5f3a\u5927\u7684\u5e93\uff0c\u901a\u8fc7google chrome\u7684F12\u4e2d\u7684network\u83b7\u53d6\u9a8c\u8bc1\u65f6\u5411\u670d\u52a1\u5668\u53d1\u9001\u7684\u5185\u5bb9\uff0c\u914d\u5408requests\u8f7b\u677e\u5199\u51fa\u811a\u672c\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>import requests\nimport time\n\ndef web_sent(user, pwd):\n    <em># \u6821\u56ed\u7f51\u767b\u5165\u94fe\u63a5\n    <\/em>url_go = <strong>\"http:\/\/172.31.99.50:804\/srun_portal_pc.php?ac_id=2&amp;\"<\/strong>\n    url_succeed = <strong>\"http:\/\/172.31.99.50:804\/srun_portal_pc_succeed.php\"\n\n    <\/strong><em># \u53d1\u9001\u7684\u6570\u636e\n    <\/em>user_data = {\n        <strong>\"action\"<\/strong>: <strong>\"login\"<\/strong>,\n        <strong>\"username\"<\/strong>: user,\n        <strong>\"password\"<\/strong>: pwd,\n        <strong>\"ac_id\"<\/strong>: <strong>\"2\"<\/strong>,\n        <em># \"save_me\": \"1\",\n        <\/em><strong>\"ajax\"<\/strong>: <strong>\"1\"\n    <\/strong>}\n\n    <em># \u5411\u76ee\u6807\u7f51\u7ad9\u53d1\u9001\u8bf7\u6c42\n    <\/em>read = 0\n    web_return = requests.post(url_go, data=user_data)\n    while web_return.text == <strong>\"Portal not response.\"<\/strong>:\n        print(web_return.text, <strong>\"<\/strong>\\n<strong>\u7f51\u9875\u65e0\u54cd\u5e94\u6b63\u5728\u91cd\u65b0\u767b\u5165...\"<\/strong>)\n        time.sleep(1) <em>#<\/em> <em>\u6bcf\u96941s\u8bf7\u6c42\u4e00\u6b21\uff0c\u907f\u514d\u670d\u52a1\u5668\u62c9\u9ed1\u3002<\/em>\n        <em># web_return = requests.post(url_go, data=user_data)\n        <\/em>read += 1\n        if read &gt;= 7:\n            print(<strong>\"\u670d\u52a1\u5668\u5fd9\u788c\uff0c\u8bf7\u91cd\u542f\u8f6f\u4ef6\u518d\u8bd5\u4e00\u6b21\uff01\uff01\uff01\"<\/strong>)\n            input(<strong>\"Press any key to continue . . .\"<\/strong>)\n            return 11\n\n    <em># \u8f93\u51fa\u7f51\u9875\u53cd\u9988\u7ed3\u679c\n    <\/em>if web_return.status_code == 200:\n        if web_return.text&#91;0:8] == <strong>\"login_ok\"<\/strong>:\n            print(<strong>\"\u767b\u5f55\u6210\u529f\uff01\uff01\uff01\"<\/strong>)\n            <em># \u83b7\u53d6ip\u548c\u8d26\u6237\u4f59\u989d\n            <\/em>succeed = requests.post(url_succeed).text\n            IP = succeed&#91;succeed.rfind(<strong>\"IP\u5730\u5740\uff1a\"<\/strong>) + 76:succeed.rfind(<strong>\"\u5df2\u7528\u6d41\u91cf\uff1a\"<\/strong>) - 59]\n            Balance = succeed&#91;succeed.rfind(<strong>\"\u5e10\u6237\u4f59\u989d\uff1a\"<\/strong>) + 80:succeed.rfind(<strong>\"&lt;\/span&gt;\"<\/strong>)]\n            while IP == <strong>''<\/strong>:\n                succeed = requests.post(url_succeed).text\n                IP = succeed&#91;succeed.rfind(<strong>\"IP\u5730\u5740\uff1a\"<\/strong>) + 76:succeed.rfind(<strong>\"\u5df2\u7528\u6d41\u91cf\uff1a\"<\/strong>) - 59]\n                Balance = succeed&#91;succeed.rfind(<strong>\"\u5e10\u6237\u4f59\u989d\uff1a\"<\/strong>) + 80:succeed.rfind(<strong>\"&lt;\/span&gt;\"<\/strong>)]\n            print(<strong>\"\u83b7\u53d6\u7684IP\u4e3a:\"<\/strong>, IP)\n            print(<strong>\"\u8d26\u6237\u4f59\u989d\uff1a\"<\/strong>, Balance, <strong>\"\uffe5\"<\/strong>)\n            input(<strong>\"Press any key to continue . . .\"<\/strong>)\n        else:\n            print(web_return.text&#91;:web_return.text.rfind(<strong>\".\"<\/strong>) + 1])\n            input(<strong>\"Press any key to continue . . .\"<\/strong>)\n\ndef main():\n    time.sleep(1)\n    user = <strong>\"0000000000\"   <\/strong> <em># \u6b64\u5904\u4e3a\u6821\u56ed\u7f51\u8d26\u53f7   <\/em> <strong>\n   <\/strong> pwd = <strong>\"000000\"       <\/strong> <em># \u6b64\u5904\u4e3a\u6821\u56ed\u7f51\u5bc6\u7801<\/em> <strong>\n    <\/strong>web_sent(user, pwd)\n\n<em># \u6267\u884c\u6307\u4ee4<\/em>\nmain()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00 \u5185\u8499\u53e4\u5927\u5b66\u6821\u56ed\u7f51\u7cfb\u6df1\u6f9c\u8f6f\u4ef6\u7684\u7f51\u9875\u8ba4\u8bc1\u7cfb\u7edf\uff0c\u6bcf\u4e2a\u8d26\u53f7\u6700\u591a\u540c\u65f6\u67093\u53f0\u8bbe\u5907\u4e0a\u7f51\uff0c\u7531\u4e8e\u79cd\u79cd\u539f\u56e0\u8ba4\u8bc1\u7f51\u9875\u65f6\u5e38\u65e0\u6cd5\u6253 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14,5,15,13],"tags":[33],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-python","category-5","category-15","category-13","tag-python"],"_links":{"self":[{"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":5,"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":169,"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions\/169"}],"wp:attachment":[{"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.constantinefun.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}