6

サーバーに http リクエストを送信し、返されたコンテンツを調べようとしています。HTTPResponse objectただし、 with をいじっipdbてみると、*** Oldest frame実行できるはずのオブジェクトで関数を実行できなくなります。フェッチを行うコードのブロックとipdb出力は次のとおりです。

コードブロック:

for acc in sp_lost:
    url = 'http://www.uniprot.org/uniprot/?query=mnemonic%3a'+acc+'+active%3ayes&format=tab&columns=entry%20name'
    u = urllib.request.urlopen(url)
    ipdb.set_trace()

ipdb 出力:

ipdb> url
'http://www.uniprot.org/uniprot/?query=mnemonic%3aSPATL_MOUSE+active%3ayes&format=tab&columns=entry%20name'
ipdb> u
*** Oldest frame
ipdb> str(u)
'<http.client.HTTPResponse object at 0xe58e2d0>'
ipdb> type(u)
<class 'http.client.HTTPResponse'>
ipdb> u.url                      
*** Oldest frame
ipdb> u.url()         # <-- unable to run url() on object...?
*** Oldest frame
ipdb> 

*** Oldest frameこのオブジェクトを、適切な関数を実行できるより便利なものにするにはどうすればよいでしょうか?

4

1 に答える 1