Python Jumpstart by Building 10 Apps Transcripts
Chapter: App 5: Real-time weather client
Lecture: Intro to the weather app
0:00 Hello and welcome to app number 5.
0:02 This time we are going to build a weather client,
0:05 it's going to go out and actually tell you
0:07 what the weather is in your location.
0:09 Now this is not a weather client simulation,
0:12 it's a real live weather client.
0:13 So it's going to go out to the internet,
0:15 find some live data, pull that back and display to the user.
0:18 It's going to be a lot of fun.
0:19 So, what it's going to look like?
0:22 It's going to have a header like all of our little apps do, saying weather client
0:26 and then it's going to ask the user for their zip code
0:28 and they are going to enter zip code
0:30 it will go out to a particular place on the internet
0:33 we'll talk about it in a minute,
0:34 find it'll lookup that zip code, get the weather,
0:38 get the forecast and display it back to the user.
0:41 So here you saw I entered 01010
0:44 and it said the weather in Brimfield Massachusetts is 32 F and clear.
0:49 And at same time the weather in Florida is 78.1 F and overcast.
0:55 So we are going to build this app and we are going to learn a lot.
0:58 The primary focus, the lesson to take from this application
1:02 is really this concept of external packages,
1:05 Python is an ecosystem described as "batteries included"
1:10 and there are sort of two levels to this meaning here
1:12 but the idea is that Python comes with everything that you need to do your job
1:17 everything you need to work with networks,
1:20 HTTP, scientific results, images, you name it.
1:24 And at one level that's the standard library built into Python
1:27 there is a ton of modules and features there,
1:30 but the sort of outer shell of that is even more amazing
1:33 there is this place called PyPi or the Python package index,
1:37 and in this package index there are many thousands of packages or libraries
1:43 that you can download and very easily add to your application.
1:48 The tool that we are going to use to do this is called pip,
1:50 so we'll talk about how you get that, how you use it,
1:53 the two extra features that we need to bring in
1:56 as an external package for our app are HTTP client,
1:59 how do I go out to the internet and grab some data and download it,
2:03 and screen scraping, how do I take semi structured
2:07 maybe malformed but mostly correct HTML
2:10 and pull that apart and understand it
2:13 and pick up just the little elements that we need
2:15 and that's called screen scraping.
2:16 For the HTTP clients we are going to use
2:18 very popular library called Requests
2:21 and for screen scraping we are going to use something called Beautiful Soup.
2:24 We are also going to talk about this concept of tuples
2:27 which is returning multiple items from a method
2:30 and a slightly nicer more usable version
2:33 that you can use called named tuples.
2:36 All right, let's get onto building that app!