{"id":2976,"date":"2012-01-25T13:52:46","date_gmt":"2012-01-25T04:52:46","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/2976"},"modified":"2012-01-26T00:12:24","modified_gmt":"2012-01-25T15:12:24","slug":"pc-%e3%81%8b%e3%82%89-iphone-%e5%b0%82%e7%94%a8%e3%82%b5%e3%82%a4%e3%83%88%e3%82%92%e8%a6%97%e3%81%8f%e6%96%b9%e6%b3%95%ef%bc%88user-agent%e3%81%ae%e5%81%bd%e8%a3%85%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/2976","title":{"rendered":"PC \u304b\u3089 iPhone \u5c02\u7528\u30b5\u30a4\u30c8\u3092\u8997\u304f\u65b9\u6cd5\uff08User-Agent\u306e\u507d\u88c5\uff09"},"content":{"rendered":"<p>\n\u7aef\u7684\u306b\u8a00\u3048\u3070\u300cUser-Agent\u300d\u3092\u507d\u88c5\u3057\u307e\u3059\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002<br \/>\nUser-Agent \u3068\u3044\u3046\u306e\u306f\u3001HTTP \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30d8\u30c3\u30c0\u90e8\u306b\u8a2d\u5b9a\u3057\u3066\u3042\u308b\u300c\u4eca\u3001\u79c1\u306f\u3053\u306e\u30d6\u30e9\u30a6\u30b6\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u300d\u3068\u3044\u3046\u5370\u3067\u3059\u306d\u3002\u30b5\u30fc\u30d0\u30fc\u306e\u307b\u3046\u3067\u3001\u643a\u5e2f\u96fb\u8a71\u304b\u3089\u306a\u306e\u304b\u3001PC \u304b\u3089\u306a\u306e\u304b\u3001iPhone\/iPad \u304b\u3089\u306a\u306e\u304b\u3001Android \u304b\u3089\u306a\u306e\u304b\u3001\u3068\u3044\u3046\u3053\u3068\u304c\u5206\u304b\u308a\u307e\u3059\u3002\n<\/p>\n<p>\n\u3068\u3001\u4e91\u3044\u307e\u3059\u304b\u3001\u5f53\u7136\u3053\u308c\u306f\u300c\u5370\uff08\u30eb\u30fc\u30eb\uff09\u300d\u3067\u3057\u304b\u306a\u304f\u3063\u3066\u3001WebClinet \u30af\u30e9\u30b9\u306a\u308a\u3001Firefox \u306e\u30d7\u30e9\u30b0\u30a4\u30f3\u3092\u5229\u7528\u3059\u308b\u3059\u308c\u3070\u3001\u7c21\u5358\u306b\u81ea\u5206\u304c\u4f55\u8005\u304b\u3092\u507d\u88c5\u3059\u308b\u3053\u304c\u3067\u304d\u307e\u3059\uff08\u300c\u8a50\u79f0\u300d\u3068\u3044\u3046\u8a00\u8449\u3092\u4f7f\u3063\u3066\u3044\u308b\u3068\u3053\u308d\u3082\u3042\u308b\u3051\u3069\u3001\u6280\u8853\u7684\u306b\u3059\u308a\u66ff\u3048\u308b\u3060\u3051\u306a\u306e\u3067\u300c\u507d\u88c5\u300d\u306e\u307b\u3046\u304c\u3088\u3044\u304b\u306a\u3068\uff09\u3002\n<\/p>\n<p>\n\u3055\u3066\u3001\u306a\u305c iphone \u5c02\u7528\u306e\u30b5\u30a4\u30c8\u3092 pc \u304b\u3089\u8997\u304f\u5fc5\u8981\u304c\u3042\u308b\u304b\u3068\u3044\u3046\u3068\u3001hon.jp \u306e api \u3092\u5229\u7528\u3057\u3066 amazon \u98a8\u306e\u30d6\u30ed\u30b0\u30d1\u30fc\u30c4\u3092\u4f5c\u308a\u305f\u3044\u304b\u3089\u306a\u306e\u3067\u3059\u3002amazon \u30d6\u30ed\u30b0\u30d1\u30fc\u30c4\u306f\u3001\u66f8\u7c4d\u306e\u753b\u50cf\u3092\u8fd4\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u3059\u304c\u3001hon.jp api \u306f\u3001\u753b\u50cf\u3092\u8fd4\u3057\u3066\u304f\u308c\u307e\u305b\u3093\u3002hon.jp \u306e\u5834\u5408\u3001\u30bf\u30a4\u30c8\u30eb\u691c\u7d22\u306a\u3069\u306e\u30c6\u30ad\u30b9\u30c8\u691c\u7d22\u304c\u4e3b\u306a\u306e\u3067\u3001\u96fb\u5b50\u66f8\u7c4d\u306e\u753b\u50cf\u306f\u5404\u793e\u306e\u30b5\u30a4\u30c8\u306e\u4e2d\u306b\u3057\u304b\u3042\u308a\u307e\u305b\u3093\u3002pc \u7528\u306e\u96fb\u5b50\u66f8\u7c4d\u304c\u3042\u308b\u5834\u5408\u306f\u3001pc \u304b\u3089\u30ad\u30e3\u30c3\u30b7\u30e5\u7684\u306b\u53d6\u5f97\u3059\u308c\u3070\u3088\u3044\u306e\u3067\u3059\u304c\u3001iphone \u7528\u3057\u304b\u306a\u3044\u5834\u5408\u306b\u306f\u3001iphone \u7528\u306e\u30da\u30fc\u30b8\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\u306a\u306e\u3067\u3001\u753b\u50cf\u3092\u53d6\u5f97\u3059\u308b\u305f\u3081\u306b\u306f iphone \u3067\u3042\u308b\u3068\u507d\u88c5\u3057\u3066\u753b\u50cf\u7528\u306e url \u3092\u53d6\u5f97\u3057\u306a\u3044\u3068\u99c4\u76ee\u306a\u306e\u3067\u3059\u3002\n<\/p>\n<p>\n\u3068\u524d\u7f6e\u304d\u306f\u305d\u308c\u304f\u3089\u3044\u306b\u3057\u3066\u3001\u3056\u3063\u3068\u3053\u3093\u306a\u611f\u3058\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nprivate void button2_Click(object sender, EventArgs e)\r\n{\r\n\t\/\/ url \u3092\u53d6\u5f97\r\n\tstring url = textBox1.Text;\r\n\tWebClientEx client = new WebClientEx();\r\n\t\/\/ cookie \u3092\u8a2d\u5b9a\r\n\tclient.Cookie = new CookieContainer();\r\n\tclient.Headers.Add(&quot;User-Agent&quot;, &quot;Mozilla\/5.0 (iPhone; U; CPU iPhone OS 4_3_4 like Mac OS X; ja-jp) AppleWebKit\/533.17.9 (KHTML, like Gecko) Version\/5.0.2 Mobile\/8K2 Safari\/6533.18.5&quot;);\r\n\t\/\/ sjis \u3067\u5168\u3066\u8aad\u307f\u8fbc\u307f\r\n\tStreamReader sr = new StreamReader(client.OpenRead(url), Encoding.GetEncoding(&quot;shift_jis&quot;));\r\n\tstring content = sr.ReadToEnd();\r\n\tsr.Close();\r\n\t\/\/ \u30d5\u30a1\u30a4\u30eb\u306b\u51fa\u529b\r\n\tStreamWriter sw = new StreamWriter(&quot;temp.html&quot;, false, Encoding.GetEncoding(&quot;shift_jis&quot;));\r\n\tsw.Write(content);\r\n\tsw.Close();\r\n\r\n\t\/\/ \u30d6\u30e9\u30a6\u30b6\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u3067\u8868\u793a\r\n\twebBrowser1.Navigate(&quot;file:\/\/&quot; + @&quot;D:\\work\\blog\\src\\SampleUserAgent\\SampleUserAgent\\bin\\Debug\\&quot;+ &quot;temp.html&quot;);\r\n\t\/\/ \u30c6\u30ad\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u3067\u3082\u8868\u793a\r\n\ttextBox2.Text = content;\r\n\r\n}\r\n<\/pre>\n<p>\n\u6587\u5b57\u30b3\u30fc\u30c9\u304c sjis \u306b\u306a\u3063\u3066\u3044\u308b\u306e\u306f\u3001\u96fb\u5b50\u6587\u5eab\u30d1\u30d6\u304c sjis \u3067\u8fd4\u3059\u304b\u3089\u3067\u3059\u3002\u672c\u6765\u306f charset \u3092\u898b\u3066\u30b3\u30fc\u30c9\u3092\u5224\u5225\u3057\u306a\u3044\u3068\u99c4\u76ee\u3067\u3059\u306d\u3002\u307e\u305f\u3001\u96fb\u5b50\u6587\u5eab\u30d1\u30d6\u306e\u5834\u5408\u306f\u3001cookie \u304c\u5fc5\u8981\u306b\u306a\u308b\u306e\u3067\u3053\u308c\u3082\u8a2d\u5b9a\u3057\u3066\u307e\u3059\u3002<br \/>\nCookie \u81ea\u4f53\u306f\u3001\u5185\u90e8\u306e HttpWebRequest \u3092\u5f04\u308b\u5fc5\u8981\u304c\u3042\u308b\u306e\u3067\u3001\u3053\u3093\u306a\u98a8\u306b\u7d99\u627f\u3057\u305f\u30af\u30e9\u30b9\u3092\u4f5c\u308a\u307e\u3059\uff08\u3068\u3044\u3046\u4f8b\u304c\u3042\u3063\u305f\uff09\u3002\n<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nclass WebClientEx : WebClient\r\n{\r\n\tpublic CookieContainer Cookie { get; set; }\r\n\tprotected override WebRequest GetWebRequest(Uri address)\r\n\t{\r\n\t\tHttpWebRequest wreq = base.GetWebRequest(address) as HttpWebRequest;\r\n\t\twreq.CookieContainer = this.Cookie;\r\n\t\treturn wreq;\r\n\t}\r\n}\r\n<\/pre>\n<p>\n\u5b9f\u884c\u3059\u308b\u3068\u3053\u3093\u306a\u611f\u3058\u3067\u53d6\u5f97\u3067\u304d\u307e\u3059\u3002\n<\/p>\n<p><a href='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2012\/01\/wpid-dworkblogimage20120125_01org.jpg'><img border='0' src='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2012\/01\/wpid-dworkblogimage20120125_01thum.jpg'\/><\/a><\/p>\n<p>\n\u753b\u50cf\u304c\u8868\u793a\u3055\u308c\u306a\u3044\u306e\u306f\u3001img \u30bf\u30b0\u306e src \u76f8\u5bfe\u30d1\u30b9\u306b\u306a\u3063\u3066\u3044\u308b\u304b\u3089\u3067\u3059\u3002<br \/>\n\u4fdd\u5b58\u3057\u305f html \u30d5\u30a1\u30a4\u30eb\u3092\u958b\u3044\u3066 <base href=\"http:\/\/www.paburi.com\/\"> \u3092\u8ffd\u52a0\u3059\u308b\u3068\u3001\u3053\u3093\u306a\u611f\u3058\u3067\u8868\u793a\u3067\u304d\u307e\u3059\u3002\n<\/p>\n<p><a href='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2012\/01\/wpid-dworkblogimage20120125_02org.jpg'><img border='0' src='http:\/\/www.moonmile.net\/blog\/wp-content\/uploads\/2012\/01\/wpid-dworkblogimage20120125_02thum.jpg'\/><\/a><\/p>\n<p>\n\u3053\u308c\u3067\u753b\u50cf\u306e url \u304c\u5206\u304b\u308b\u306e\u3067\u3001\u30d6\u30ed\u30b0\u30d1\u30fc\u30c4\u3092\u8868\u793a\u3059\u308b\u6642\u306b\u753b\u50cf\u304c\u8868\u793a\u3067\u304d\u307e\u3059\u306d\u3002<br \/>\n\u753b\u50cf url \u304c\u5909\u308f\u308b\u53ef\u80fd\u6027\u3082\u3042\u308b\u306e\u3067\u30ad\u30e3\u30c3\u30b7\u30e5\u3057\u3066\u3082\u3044\u3044\u306e\u3067\u3059\u304c\u3001\u307e\u3041\u3001amazon \u3068\u540c\u3058\u3067\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u540d\u306f\u307b\u3068\u3093\u3069\u5909\u308f\u3089\u306a\u3044\u306e\u3067\u306f\u306a\u3044\u304b\u306a\u3068\u3002\u3053\u308c\u306f\u3001\u3044\u304f\u3064\u304b\u306e\u96fb\u5b50\u66f8\u7c4d\u306e\u4f1a\u793e\u3092\u63a2\u3063\u3066\u304b\u3089\u8003\u3048\u307e\u3057\u3087\u3046\u3002\n<\/p>\n<p>\u25a0\u53c2\u8003<br \/>\nuserAgent\u4e00\u89a7\/\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u4e00\u89a7<br \/>\n<a href=\"http:\/\/www.openspc2.org\/userAgent\/\">http:\/\/www.openspc2.org\/userAgent\/<br \/>\n<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7aef\u7684\u306b\u8a00\u3048\u3070\u300cUser-Agent\u300d\u3092\u507d\u88c5\u3057\u307e\u3059\u3001\u3068\u3044\u3046\u3053\u3068\u3067\u3059\u3002 User-Agent \u3068\u3044\u3046\u306e\u306f\u3001HTTP \u30d7\u30ed\u30c8\u30b3\u30eb\u306e\u30d8\u30c3\u30c0\u90e8\u306b\u8a2d\u5b9a\u3057\u3066\u3042\u308b\u300c\u4eca\u3001\u79c1\u306f\u3053\u306e\u30d6\u30e9\u30a6\u30b6\u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u300d\u3068\u3044\u3046\u5370\u3067\u3059\u306d\u3002\u30b5\u30fc\u30d0\u30fc\u306e\u307b\u3046\u3067\u3001\u643a &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/2976\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[23],"tags":[],"class_list":["post-2976","post","type-post","status-publish","format-standard","hentry","category-csharp"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2976","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=2976"}],"version-history":[{"count":2,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2976\/revisions"}],"predecessor-version":[{"id":2978,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/2976\/revisions\/2978"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=2976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=2976"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=2976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}