{"id":449,"date":"2017-02-07T22:26:10","date_gmt":"2017-02-07T14:26:10","guid":{"rendered":"http:\/\/www.rainweb.site\/?p=449"},"modified":"2023-08-07T20:57:30","modified_gmt":"2023-08-07T12:57:30","slug":"python-article34","status":"publish","type":"post","link":"http:\/\/rain1024.com\/index.php\/2017\/02\/07\/python-article34\/","title":{"rendered":"\u4f7f\u7528\u722c\u866b\u591a\u79cd\u59ff\u52bf\u722c\u53d6\u5b66\u6821OnlineJudge\u4e0a\u7684\u9898\u76ee"},"content":{"rendered":"<h2>\u722c\u866b\u6bcf\u65e5\u7bc7----\u4f7f\u7528\u722c\u866b\u591a\u79cd\u59ff\u52bf\u722c\u53d6\u5b66\u6821OnlineJudge\u4e0a\u7684\u9898\u76ee\u3002\u5b66\u6821\u7684oj\u91cc\u6709\u4e24\u5343\u591a\u9053\u9898\uff0c\u5230\u8bbf\u95ee\u7684\u65f6\u5019\u5fc5\u987b\u8fde\u6821\u56ed\u7f51\uff0c\u5728\u5916\u9762\u5c31\u770b\u4e0d\u5230\u4e86\uff0c\u6240\u4ee5\u6211\u60f3\u7740\u628a\u4e0a\u9762\u6240\u6709\u7684\u9898\u90fd\u5f04\u4e0b\u6765\uff0c\u7136\u540e\u628a\u6240\u6709\u9898\u76ee\u96c6\u5408\u5230\u4e00\u8d77\u505a\u4e00\u4e2a.chm\u65b9\u4fbf\u7528\u7684\u65f6\u5019\u770b\u3002\u6548\u679c\u5982\u4e0b\u56fe\u3002<\/h2>\n<h2>\u5b66\u6821OJ\u7f51\u7ad9\u7684\u914d\u7f6e\u5f88\u7b80\u5355\uff0c\u666e\u901a\u7684http\u534f\u8bae\uff0c\u4f7f\u7528get\u8bf7\u6c42\u5c31\u53ef\u4ee5\u3002\u76f4\u63a5\u4e0a\u4ee3\u7801\uff0c\u6709\u4e0d\u61c2\u7684\u53ef\u4ee5\u8054\u7cfb\u6211\u7684\u90ae\u7bb1\u3002<\/h2>\n<h2>\u722c\u53d61000-1050\u9898\u53f7\u4e4b\u95f4\u6240\u6709\u7684\u9898\u76ee<\/h2>\n<pre><code class=\"python\">import urllib\nimport urllib2\nimport string\nurl = 'http:\/\/210.31.181.254\/JudgeOnline\/showproblem?problem_id='\nfor id in range(1000,1050):\n    result = urllib2.urlopen(url+str(id))\n    f = open('test\/'+str(id)+'.html','w')\n    f.write(result.read())\n    f.close()\n<\/code><\/pre>\n<h1>## \u722c\u53d6\u5bf9\u5e94\u8d26\u53f7\u505a\u8fc7\u7684\u6240\u6709\u9898\u76ee<\/h1>\n<pre><code class=\"python\">import urllib\nimport urllib2\nimport string\nimport re\nurl = 'http:\/\/210.31.181.254\/JudgeOnline\/showproblem?problem_id='\nlogin_url = 'http:\/\/210.31.181.254\/JudgeOnline\/login?action=login'\nproblem_list_url = 'http:\/\/210.31.181.254\/JudgeOnline\/problemlist'\nuser_url = 'http:\/\/210.31.181.254\/JudgeOnline\/userstatus?user_id='\nuser_id = 0;\ndata = urllib.urlencode({\n    'user_id1':'2015xxxxxx',\n    'password1':'xxxxxx',\n    'B1':'login'\n})\nuser_agent = 'Mozilla\/4.0 (compatible; MSIE 5.5; Windows NT)'\nheaders = {'User-Agent':user_agent}\nrequest = urllib2.Request(login_url,data,headers)\nresponse = urllib2.urlopen(request)\nprint response.read()\nuser_id = 2015110;\nresult = urllib2.urlopen(user_url+str(user_id)).read()\nresult = re.findall('problem_id=?([\\d][\\d][\\d][\\d])',result)\nfor id in result:\n    problem = urllib2.urlopen(url+id)\n    f = open('test\/'+id+'.html','w')\n    f.write(problem.read())\n    f.close()\n# &lt;a href.*problem_id=.*&gt;\n# f = open('thefile.txt','w')\n# f.write(result.)\n# f.close()\nprint result\n<\/code><\/pre>\n<h4>\u4e0b\u9762\u662f\u6548\u679c\u56fe<\/h4>\n<p><img decoding=\"async\" src=\"http:\/\/blog-1252406596.costj.myqcloud.com\/blog\/python15.png\" alt=\"\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u722c\u866b\u6bcf\u65e5\u7bc7&#8212;-\u4f7f\u7528\u722c\u866b\u591a\u79cd\u59ff\u52bf\u722c\u53d6\u5b66\u6821OnlineJudge\u4e0a\u7684\u9898\u76ee\u3002\u5b66\u6821\u7684oj\u91cc\u6709\u4e24\u5343\u591a\u9053\u9898\uff0c\u5230\u8bbf\u95ee\u7684\u65f6\u2026 <span class=\"read-more\"><a href=\"http:\/\/rain1024.com\/index.php\/2017\/02\/07\/python-article34\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":380,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"aside","meta":{"footnotes":""},"categories":[15],"tags":[58,81],"class_list":["post-449","post","type-post","status-publish","format-aside","has-post-thumbnail","hentry","category-python","tag-python","tag-reptile","post_format-post-format-aside"],"_links":{"self":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/comments?post=449"}],"version-history":[{"count":1,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/449\/revisions"}],"predecessor-version":[{"id":1506,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/posts\/449\/revisions\/1506"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media\/380"}],"wp:attachment":[{"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/media?parent=449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/categories?post=449"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/rain1024.com\/index.php\/wp-json\/wp\/v2\/tags?post=449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}