#100DaysOfCode in Python Transcripts
Chapter: Days 52-54: Parsing RSS feeds with Feedparser
Lecture: Pulling the feed with Requests

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Okay, let's get cracking.
0:01 First thing we need to do is import requests, sorry.
0:07 import requests.
0:09 Now I know you probably know how to use requests
0:12 so I'm not going over this too much.
0:14 But what I'd like you to do is
0:15 enter the URL of your feed.
0:18 Now to get that for example,
0:20 we're going to be pulling the
0:23 new releases XML feed from Steam.
0:26 Stored up, steam powered.
0:28 Okay,
0:29 all I've done to get that is just Google
0:31 "Steam Feed."
0:33 Came up here,
0:34 I just grab the first one
0:35 and there was a link on the website for
0:38 their RSS feed.
0:39 Okay, this is the news one,
0:41 but we're actually
0:42 going to use the new releases
0:43 for the video games.
0:45 So you can feel free to grab whatever you want
0:47 and once you do that,
0:49 just pop the URL into here
0:52 and assign it to URL.
0:57 So there's mine there.
0:59 Next, we're just going to use our standard
1:02 Python and dunder there.
1:05 Okay,
1:06 and then what we're going to do is
1:08 we're going to
1:10 requests.get.
1:12 So, essentially,
1:13 we're going to get that URL
1:14 and we're going to store it
1:16 or we're going to assign it to the r variable.
1:19 Okay, and then we're actually going to
1:21 write the contents of this file,
1:24 of this XML feed, this that you're pulling down,
1:28 we're going to write that down to an XML file.
1:30 Okay, so to do that,
1:32 just going to do it the old fashioned way.
1:34 We're going to open a file, let's just call it
1:37 newreleases.
1:39 Just like the actual XML.
1:42 We're just going to write binary
1:43 and we're going to open it as f.
1:46 And I'm using that with Statement as usual
1:49 just to make sure it closes
1:50 out right when it's done.
1:53 So, we're going to write
1:55 r.content.
1:58 I'm not explaining this in detail
1:59 because you would have experienced requests
2:02 by now, so that should be nice and familiar.
2:05 But this is necessary to pull down the file.
2:08 Alright, so we save that, that's all we need.
2:11 Now, head over here to your shell.
2:13 Woops, we don't actually want to launch the shell,
2:18 We want to go Python pull_xml.py.
2:22 Alright, that completed.
2:25 Now, if we bring up our folder here,
2:28 or everything that's inside,
2:30 you will have seen it's created in newreleases XML file.
2:34 Alright,
2:36 that's it there.
2:38 Now, we'll open that file
2:42 in explorer.
2:43 Where are we?
2:45 Open, let's just choose, okay, don't hate me.
2:48 Let's just choose internet explorer.
2:51 So, now that this is open,
2:53 you can have a good look at what's inside this XML file.
2:57 Pay attention, maybe while you're doing this for yours, just open this,
3:01 your XML feed
3:02 in a browser
3:04 or in your favorite editor,
3:06 just so you can have a look at these little tags here.
3:09 So pay attention to that,
3:10 we'll talk about them in the next video.