I would like to say something about urllib , urllib2 , httplib and httplib2 .
The main difference between urllib* and httplib* is this:
httplib and httplib2 process the HTTP / HTTP request and response directly and give you more space to do your own work.
urllib and urllib2 are built on httplib, they are more abstract and powerful, but sometimes they will not fulfill your specified need for some HTTP-related operations.
And for httplib and httplib2 I would say that they are both HTTP client library . However, httplib2 much more efficient and has much more features than httplib .
Regarding urllib and urllib2 , enter a quote from this link :
urllib and urllib2 are both Python modules that are associated with URL requests but offer different functions. The two most significant differences are listed below:
- urllib2 can accept a Request object to set headers for requesting a url, urllib only accepts a url. This means that you cannot mask your User Agent string, etc.
- urllib provides a urlencode method that is used to generate GET request strings, urllib2 does not have such a function. This is one of the reasons urllib is often used with urllib2.
I would recommend my personal blog Httplib Httplib2 Urllib Urllib2-whats the Difference .
Hope this helps :-)
Lihang Li Nov 14 '13 at 9:10 2013-11-14 09:10
source share