{"id":2618,"date":"2013-03-08T20:12:17","date_gmt":"2013-03-08T11:12:17","guid":{"rendered":"http:\/\/www.lancard.com\/blog\/?p=2618"},"modified":"2025-03-12T11:29:02","modified_gmt":"2025-03-12T02:29:02","slug":"ironpython%e3%81%a7%e3%82%82requests%e3%81%8c%e4%bd%bf%e3%81%84%e3%81%9f%e3%81%84","status":"publish","type":"post","link":"https:\/\/www.lancard.com\/blog\/2013\/03\/08\/ironpython%e3%81%a7%e3%82%82requests%e3%81%8c%e4%bd%bf%e3%81%84%e3%81%9f%e3%81%84\/","title":{"rendered":"IronPython\u3067\u3082Requests\u304c\u4f7f\u3044\u305f\u3044"},"content":{"rendered":"<p>Requests: \u4eba\u9593\u306e\u305f\u3081\u306eHTTP<br \/>\n<a href=\"http:\/\/ja.python-requests.org\/en\/latest\/\" target=\"_blank\">http:\/\/ja.python-requests.org\/en\/latest\/<\/a><\/p>\n<p>Python\u306e\u4fbf\u5229\u306aHTTP\u30e9\u30a4\u30d6\u30e9\u30ea Requests \u3092 IronPython \u3067\u3082\u4f7f\u3044\u305f\u3044\u308f\u3051\u3067\u3059\u3002<br \/>\n\u3053\u3093\u306a\u3053\u3068\u3092\u66f8\u3044\u3066\u3044\u308b\u3068\u3044\u3046\u3053\u3068\u306f\u7d20\u76f4\u306b\u306f\u4f7f\u3048\u306a\u3044\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u4e00\u5fdc\u52d5\u4f5c\u3057\u3066\u308b\u304b\u306a\u301c\u3001\u3068\u3044\u3046\u3068\u3053\u308d\u307e\u3067\u884c\u3051\u305f\u306e\u3067\u30e1\u30e2\u3057\u3068\u304d\u307e\u3059\u3002IronPython \u306f 2.7.3 \u3067\u3001Requests \u306f 1.1.0 \u3067\u3059\u3002<\/p>\n<p>\u30dd\u30a4\u30f3\u30c8\u306f\uff12\u3064\u3002<\/p>\n<p>\u307e\u305a\u4e00\u3064\u76ee\u3002<\/p>\n<p>sys._getframe \u304c\u5fc5\u8981\u306a\u306e\u3067 ipy.exe (or ipy64.exe)\u3000\u306b -X:Frames \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u3066\u8d77\u52d5\u3059\u308b\u3002<\/p>\n<p>\u30aa\u30d7\u30b7\u30e7\u30f3\u306f\u3053\u3093\u306a\u611f\u3058\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre lang=\"dos\">\r\nC:\\Users\\murave>ipy -help\r\nUsage: ipy.exe Usage: ipy [options] [file.py|- [arguments]]\r\n <\u524d\u7565>\r\n -X:Frames                Enable basic sys._getframe support\r\n <\u5f8c\u7565>\r\n<\/pre>\n<p>\uff12\u3064\u76ee\u3002IronPython \u306b\u306f idna \u30a8\u30f3\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u304c\u306a\u3044\u306e\u3067\u56de\u907f\u3059\u308b\u3002<\/p>\n<p>requests \u306e models.py \u3067\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u306e\u3067\u53d6\u308a\u6562\u3048\u305a\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3002<\/p>\n<p>idna\u3067\u691c\u7d22\u3059\u308b\u3068290\u884c\u76ee\u3042\u305f\u308a\u3067\u4f7f\u7528\u3055\u308c\u3066\u307e\u3059\u3002<\/p>\n<pre lang=\"python\">\r\n#        try:\r\n#            netloc = netloc.encode('idna').decode('utf-8')\r\n#        except UnicodeError:\r\n#            raise InvalidURL('URL has an invalid label.')\r\n<\/pre>\n<p>netloc = netloc.encode(&#8216;utf-8&#8217;).decode(&#8216;utf-8&#8217;) \u306b\u66f8\u304d\u63db\u3048\u3066\u307f\u305f\u308a\u3082\u3057\u305f\u306e\u3067\u3059\u304c\u99ac\u9e7f\u3089\u3057\u3044\u6c17\u304c\u3059\u308b\u306e\u3067\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u307e\u3057\u305f\u3002<br \/>\n\u304a\u305d\u3089\u304f\u3053\u306e\u5f71\u97ff\u3067\u300c\u30c9\u30e1\u30a4\u30f3\u3068URL\u306e\u56fd\u969b\u5316\u300d\u306f\u672a\u5bfe\u5fdc\u306b\u306a\u3063\u3066\u3057\u307e\u3063\u3066\u307e\u3059\u304c\u3001\u52d5\u304b\u306a\u3044\u3088\u308a\u306f\u3044\u3044\u304b\u3068\u3002<\/p>\n<pre lang=\"python\">\r\nC:\\Users\\murave>ipy -X:Frames\r\nIronPython 2.7.3 (2.7.0.40) on .NET 4.0.30319.18010 (32-bit)\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import requests\r\n>>> import json\r\n>>> r = requests.get('http:\/\/172.16.191.1:8001\/api\/v1_0\/poll\/')\r\n>>> r.text\r\nu'{\"meta\": {\"limit\": 20, \"next\": null, \"offset\": 0, \"previous\": null, \"total_cou\r\nnt\": 3}, \"objects\": [{\"id\": 1, \"pub_date\": \"2013-03-05T13:51:15\", \"question\": \"W\r\nhat\\'s up?\", \"resource_uri\": \"\/api\/v1_0\/poll\/1\/\"}, {\"id\": 2, \"pub_date\": \"2013-0\r\n3-06T10:01:35\", \"question\": \"\\u65e5\\u672c\\u8a9e\\u30c6\\u30b9\\u30c8\", \"resource_ur\r\ni\": \"\/api\/v1_0\/poll\/2\/\"}, {\"id\": 3, \"pub_date\": \"2013-03-06T13:51:15\", \"question\r\n\": \"\\u3044\\u3044\\u3044\", \"resource_uri\": \"\/api\/v1_0\/poll\/3\/\"}]}'\r\n>>> res = r.json()\r\n>>> print res['objects'][1]['question']\r\n\u65e5\u672c\u8a9e\u30c6\u30b9\u30c8\r\n>>> payload = {\"pub_date\": \"2013-03-08T20:19:15\", \"question\": \"\u3069\u3046\u304b\u306d\uff1f\"}\r\n>>> r = requests.post('http:\/\/172.16.191.1:8001\/api\/v1_0\/poll\/', data=json.dumps(payload), headers={\"Content-Type\": \"application\/json\"})\r\n>>> r \r\n<Response [201]>\r\n>>> payload = {\"pub_date\": \"2013-03-08T20:19:15\", \"question\": \"put\u306f\uff1f\"}\r\n>>> r = requests.put('http:\/\/172.16.191.1:8001\/api\/v1_0\/poll\/1\/', data=json.dumps(payload), headers={\"Content-Type\": \"application\/json\"})\r\n>>> r\r\n<Response [204]>\r\n>>> r = requests.delete('http:\/\/172.16.191.1:8001\/api\/v1_0\/poll\/1\/')\r\n>>> r\r\n<Response [204]>\r\n<\/pre>\n<p>\u3068\u3001requests.get\u3001requests.post\u3001requests.put\u3001requests.delete \u52d5\u3044\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-facebook nolightbox\" data-provider=\"facebook\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Facebook\" href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2618&#038;t=IronPython%E3%81%A7%E3%82%82Requests%E3%81%8C%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84&#038;s=100&#038;p&#091;url&#093;=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2618&#038;p&#091;images&#093;&#091;0&#093;=&#038;p&#091;title&#093;=IronPython%E3%81%A7%E3%82%82Requests%E3%81%8C%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"Facebook\" title=\"Share on Facebook\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/facebook.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-twitter nolightbox\" data-provider=\"twitter\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Twitter\" href=\"http:\/\/twitter.com\/share?url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2618&#038;text=IronPython%E3%81%A7%E3%82%82Requests%E3%81%8C%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"twitter\" title=\"Share on Twitter\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/twitter.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-linkedin nolightbox\" data-provider=\"linkedin\" target=\"_blank\" rel=\"nofollow\" title=\"Share on Linkedin\" href=\"https:\/\/www.linkedin.com\/shareArticle?mini=true&#038;url=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2618&#038;title=IronPython%E3%81%A7%E3%82%82Requests%E3%81%8C%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"linkedin\" title=\"Share on Linkedin\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/linkedin.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-tumblr nolightbox\" data-provider=\"tumblr\" target=\"_blank\" rel=\"nofollow\" title=\"Share on tumblr\" href=\"https:\/\/tumblr.com\/share?s=&#038;v=3&#038;t=IronPython%E3%81%A7%E3%82%82Requests%E3%81%8C%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84&#038;u=https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2618\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px;margin-right:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"tumblr\" title=\"Share on tumblr\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/tumblr.png\" \/><\/a><a class=\"synved-social-button synved-social-button-share synved-social-size-24 synved-social-resolution-single synved-social-provider-mail nolightbox\" data-provider=\"mail\" rel=\"nofollow\" title=\"Share by email\" href=\"mailto:?subject=IronPython%E3%81%A7%E3%82%82Requests%E3%81%8C%E4%BD%BF%E3%81%84%E3%81%9F%E3%81%84&#038;body=%E3%82%B7%E3%82%A7%E3%82%A2%E3%81%99%E3%82%8B%EF%BC%9A:%20https%3A%2F%2Fwww.lancard.com%2Fblog%2Fwp-json%2Fwp%2Fv2%2Fposts%2F2618\" style=\"font-size: 0px;width:24px;height:24px;margin:0;margin-bottom:5px\"><img loading=\"lazy\" decoding=\"async\" alt=\"mail\" title=\"Share by email\" class=\"synved-share-image synved-social-image synved-social-image-share\" width=\"24\" height=\"24\" style=\"display: inline;width:24px;height:24px;margin: 0;padding: 0;border: none;box-shadow: none\" src=\"https:\/\/www.lancard.com\/blog\/wp-content\/plugins\/social-media-feather\/synved-social\/image\/social\/regular\/48x48\/mail.png\" \/><\/a>","protected":false},"excerpt":{"rendered":"<p>Requests: \u4eba\u9593\u306e\u305f\u3081\u306eHTTP http:\/\/ja.python-requests.org\/en\/latest\/ Python\u306e\u4fbf\u5229\u306aHTTP\u30e9\u30a4\u30d6\u30e9\u30ea Requests \u3092 IronPython \u3067\u3082\u4f7f\u3044\u305f\u3044 [&hellip;]<\/p>\n","protected":false},"author":12,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[32],"class_list":["post-2618","post","type-post","status-publish","format-standard","hentry","category-python","tag-ironpython"],"_links":{"self":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2618","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/users\/12"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/comments?post=2618"}],"version-history":[{"count":14,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2618\/revisions"}],"predecessor-version":[{"id":8227,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/posts\/2618\/revisions\/8227"}],"wp:attachment":[{"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/media?parent=2618"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/categories?post=2618"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lancard.com\/blog\/wp-json\/wp\/v2\/tags?post=2618"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}