课程: Python Essential Libraries
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Creating basic requests
- [Narrator] Sending and receiving data with the requests library is really easy to get started with, so we'll begin there. In your editor, let's open up the basicreqs underscore start file. In the code, you can see I have already imported the requests library. So, let's start with a basic http GET request to retrieve some data from the internet. And if you're already familiar http verbs, then you'll know that a GET request is used to get the contents of a patricular URL. To do this with requests, you simply use the get function, which returns a http response object. So I'll create a variable to hold the response, and then I'll call requests dot get. And as I said earlier, I'm going to be using the free http bin website to test out our code. So in this case, I'm going to request some sample XML data which is available at the XML end point. So, I'll go ahead, oops, I didn't put that in quotes. And that's going to be http…
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。