Return to Video

Parsing RSS - Web Development

  • 0:00 - 0:04
    And the answer, at least at the time of writing, is 16.
  • 0:04 - 0:06
    And if it's actually different from 16,
  • 0:06 - 0:08
    we'll have our grading script update accordingly.
  • 0:08 - 0:10
    Let me show you how I arrived to this answer.
  • 0:10 - 0:13
    All right. So here we are in Python I first import the libraries I need.
  • 0:13 - 0:16
    URL of two and Mini dom.
  • 0:16 - 0:19
    Okay and then I download the New York Times page.
  • 0:19 - 0:23
    I'm going to use URL lib to URL open and I'm pasting the URL.
  • 0:23 - 0:26
    I'm going to go ahead and call read on that to download the contents and
  • 0:26 - 0:28
    we're going to store that under a variable called contents.
  • 0:28 - 0:29
    We can take a peek at contents.
  • 0:29 - 0:30
    There we go.
  • 0:30 - 0:32
    A lot of stuff and looks like RSS.
  • 0:32 - 0:34
    We can see the closing RSS tag there.
  • 0:34 - 0:36
    Now we're going to parse this with Mini Dom.
  • 0:36 - 0:39
    Okay. That worked, got a variable d, it's got a document instance, and
  • 0:39 - 0:45
    I'm going to use get elements by tag name, item, to find all of those.
  • 0:45 - 0:47
    So let's give this a whirl.
  • 0:47 - 0:48
    Success.
  • 0:48 - 0:50
    And then we just run length on this.
  • 0:50 - 0:52
    Okay and the answer's 18 [LAUGH].
  • 0:52 - 0:54
    So grading this is actually going to be a little tricky for
  • 0:54 - 0:57
    us, all we wanted you to do is go through this process.
  • 0:57 - 1:00
    So hopefully, that worked out for you and you got a number.
  • 1:00 - 1:03
    And hopefully, we managed to grade that number.
  • 1:03 - 1:07
    That's how you parse some basic XML, I think you can see probably, the value
  • 1:07 - 1:13
    here and that many webpages have XML, interfaces them, or RSS interfaces them.
  • 1:13 - 1:14
    Where you can actually download their content, and
  • 1:14 - 1:15
    manipulate it, from a program.
Cím:
Parsing RSS - Web Development
Leírás:

15-12 Parsing RSS

more » « less
Video Language:
English
Team:
Udacity
Projekt:
CS253 - Web Development
Duration:
01:16
Udacity Robot edited Angol subtitles for 15-12 Parsing RSS
Udacity Robot edited Angol subtitles for 15-12 Parsing RSS
Cogi-Admin edited Angol subtitles for 15-12 Parsing RSS

English subtitles

Felülvizsgálatok Compare revisions