From the course: Learning Python
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Retrieving internet data - Python Tutorial
From the course: Learning Python
Retrieving internet data
- [Instructor] One of the areas where Python really shines is in retrieving and working with data from the internet such as JSON and XML. In this chapter, we'll see how to work with those data types, but first we need to understand how to use Python to access the internet. So let's go ahead and open up the inetdata start example. And of course, if you're using CoLabs, just go ahead and create a new code cell to follow along. So in this first example, we're going to just retrieve data from a server and print the results. So the Python standard library includes a module that lets us make internet requests. It's called URLLib.request. So I'm going to import that module here. This module provides the classes and code that I need to make HTTP requests. So what I'm going to do is create a variable and I'll call that web URL, and I'm going to assign that to the result of calling URLLib.request.URLopen. There we go. And all I have to do is give it the URL I want. So I'm going to call http…