On 08/05/17 16:23, Rafael Knuth wrote: > Which package should I use to fetch and open an URL? > I am using Python 3.5 and there are presently 4 versions: > > urllib2 > urllib3 > urllib4 > urllib5
I don't know where you are getting those from but the standard install of Python v3.6 only has urllib. This is a package with various modules inside. ISTR there was a urllib2 in Python 2 for a while but I've never heard of any 3,4, or 5. > Then, there is another package, along with a dozen other > urllib-related packages (such as aiourllib). Again, where are you finding these? They are not in the standard library. Have you been installing other packages that may have their own versions maybe? > urllib.request > > The latter I found on http://docs.python-requests.org along with these > encouraging words: > > "Warning: Recreational use of the Python standard library for HTTP may > result in dangerous side-effects, including: security vulnerabilities, > verbose code, reinventing the wheel, constantly reading documentation, > depression, headaches, or even death." That's true of almost any package used badly. Remember that this is "marketing" propaganda from an alternative package maintainer. And while most folks (including me)seem to agree that Requests is easier to use than the standard library, the standard library version works just fine if you take sensible care. > How do I know where to find the right package There is no right package, just the one you find most effective. Most folks would say that Requests is easier to use than the standard library, if you are doing anything non-trivial I'd second that opinion. > I found some code samples that show how to use urllib.request, now I > am trying to understand why I should use urllib.request. Because as part of the standard library you can be sure it will be thee, whereas Requests is a third party module that needs to be downloaded/installed and therefore may not be present (or even allowed by the server admins) Or maybe because you found some old code written before Requests became popular and you need to integrate with it or reuse it. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor