Get outgoing port number from urllib2
问题 I am using Python 2.6.x and urllib2 to do some web scraping, but I need really low-level socket information (really just the port number of the local socket) for each HTTP request. Does anyone know how to get that? Thanks EDIT: Okay, I'm still trying to get this right, so I did what I thought should work but I'm not getting the output when I try and use the new stuff. What am I doing wrong here? from urllib2 import * class AbstractHTTPHandler(AbstractHTTPHandler): def do_open(self, http_class