LoginSignup
2
1

More than 5 years have passed since last update.

[Python] urllib2.urlopenが遅い時の対処法

Posted at

概要

Pythonでurllib2.urlopenを使用する時にデータの取得に時間が掛かることがあり、その対処法として参考になるコードを見つけたので記載しておきます。

対処法

import socket

def getAddrInfoWrapper(host, port, family=0, socktype=0, proto=0, flags=0):
    return origGetAddrInfo(host, port, socket.AF_INET, socktype, proto, flags)

origGetAddrInfo = socket.getaddrinfo
socket.getaddrinfo = getAddrInfoWrapper

参考

Pythonでurlopenが遅い
http://d.hatena.ne.jp/yuta1228/20110626/1309075278

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1