{"width":"100%","image_url":null,"url":"https://tk0miya.hatenablog.com/entry/20120623/p1","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Ftk0miya.hatenablog.com%2Fentry%2F20120623%2Fp1\" title=\"\u7d9a\u30fburllib2 \u3067 timeout \u3092\u6355\u307e\u3048\u308b - Hack like a rolling stone\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>","height":"190","blog_url":"https://tk0miya.hatenablog.com/","author_name":"tk0miya","categories":[],"version":"1.0","provider_url":"https://hatena.blog","provider_name":"Hatena Blog","blog_title":"Hack like a rolling stone","title":"\u7d9a\u30fburllib2 \u3067 timeout \u3092\u6355\u307e\u3048\u308b","published":"2012-06-23 00:00:02","author_url":"https://blog.hatena.ne.jp/tk0miya/","type":"rich","description":"6/26 \u8ffd\u8a18: Python2.7.3 \u306b\u3064\u3044\u3066\u8ffd\u8a66urllib2 \u3092\u4f7f\u3063\u3066 Web API \u3092\u547c\u3073\u51fa\u3059\u5834\u5408\u3001\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u304c\u6c17\u306b\u306a\u308a\u307e\u3059\u3088\u306d\u3002 urllib2 \u3067\u306f urllib.urlopen() \u306e\u5f15\u6570\u306b timeout \u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002 import urllib2 urllib2.urlopen('http://www.yahoo.co.jp/', timeout=1) \u305d\u308c\u3067\u306f\u3001\u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u304c\u767a\u751f\u3057\u305f\u3053\u3068\u306f\u3069\u306e\u3088\u3046\u306b\u5f97\u3089\u308c\u308b\u306e\u3067\u3057\u3087\u3046\u304b\u3002 \u5b9f\u9a13\u3057\u3066\u307f\u305f\u3068\u3053\u308d\u4f8b\u5916 urllib2.URLError \u304c\u767a\u751f\u3057\u3066\u3044\u305f\u306e\u3067\u3001 import urllib2 import timeo\u2026"}