Placeholder Image

字幕表 動画を再生する

  • What's going on?

  • Everybody welcome to part 13 of the go language tutorial.

  • Siri's in this tutorial.

  • Ramadan is just building on the last tutorial with our news aggregator Web app idea.

  • In the previous tutorial we were talking about looping and how we could loop over this thing information we're pulling, which in this case is just a bunch of site maps.

  • Now, what we want to do is actually visit those site maps and then pull the information from there, which is actually the look.

  • You know, the actual articles themselves, their titles and keywords, stuff like that.

  • So that's what we're gonna be doing here.

  • We also need to clean this up a little bit.

  • I kind of was really explicit with every part that we wanted to break down here.

  • But what we can do is actually we can We can simplify this quite a bit.

  • So it's all just one structure, which is gonna make sense.

  • You wouldn't want to.

  • I mean, you can break him down.

  • Is this far if you really wanted to.

  • The problem is, as this program grows, that's going to get super problematic, like we like to do the next the next site map in all the information that we want from there, which will be titles, keywords and the location you're gonna end up with, like 15 Struck's if you're not careful.

  • So So let's go ahead and clean this up at least a little bit.

  • So, um, one of things that we could do right out of the gate is like, if you'll notice here, Site map index is a you know, it's Luke has just one value in it, which is locations, which is a slice of the location type.

  • Well, if we look at the location type, it turns out that's just a string type.

  • Uh, and so all we really need to do at this point would be to take rather than have locations be a location type.

  • We can actually just make that clustering type, and that solves.

  • This problem here will turn extent.

  • We also need to reference the tag itself.

  • So its location inside of the site map tag.

  • So to handle for that, you just do a greater than sign and go to the next tag.

  • So this means the location tag underneath the site map tag.

  • So, um, so now If you just make that slight change, we can actually get rid of both the location struck.

  • But we can also get rid of this string method because we don't actually need that anymore, because now it's a string type as we generate over locations.

  • So, um, that definitely simplifies things quite a bit for us.

  • So now we want to talk a little bit about what happens when we go and visit one of the site maps from here.

  • So let me go ahead and just pull one up real quick just so we can kind of see what we're working with.

  • So I'll just pull up the pole politics, say, mapping on.

  • Bring that over.

  • So here is that.

  • Let me just make it fit says you can see here this time everything is contained in the most parents.

  • Tag is your el set, and then inside of you are all set.

  • You've got u R l inside of the u r l tang.

  • We have the location.

  • We've got n colon news, the publication You've got title keywords.

  • All that, um, and the end colon news is something I'm I don't really see to too much.

  • I'm guessing they're just calling this, like why they're using n colon.

  • I don't really know.

  • Someone's, like, super familiar with XML.

  • And you wanna let us know why they do end colon rather than just news?

  • Because basically, this is still a news tag.

  • It's just like a news tag of of and which I guess is, you know, new.

  • I'm guessing his news, but it makes no sense to me.

  • Why didn't you just call the tag news?

  • So if anybody can answer that question, let me know Anybody from Washington Post watching anyway, um, wondering where all the new traffic is coming from moving along.

  • Um, so, anyways, this is what we want apart, So the structure is a little different.

  • So just again, just you can pull this up.

  • You go to the text based version.

  • I have a sample of this, So if things do change, you're in luck.

  • I gotta sample just like I did before that you could still work with or you can adapt this to your own, but basically we know we're going to go inside the aural set inside the u.

  • R.

  • L.

  • One of the things we are interested in is the location tag, but we're also gonna be interested in from inside the whorl inside the news tank.

  • We also want title in probably keywords.

  • So quite a bit more structure that we want to pull in.

  • And that's why we want to really get our struck's perfect.

  • Because otherwise we're gonna like I was saying before end up with, like, 30 Struck's probably more like like, 10 strokes or something like that, but it would be kind of absurd.

  • So, uh, so that's our site map index trucked.

  • Let's go ahead and build a new struck in that when they're basically a new type and that's gonna be type news.

  • And of course, it'll be instruct.

  • And then inside news, this one's going to have titles which will be a slice in the string form, and the location of this you still be here is gonna be It's gonna be XML tax.

  • And then, like we were discussing, it's the girl and then it's within.

  • Remember, it was End Colin news, but for some reason I'm not.

  • I'm not even sure what the official name for something like this would be, but you don't use that you're just going to say, OK, it's in the news tag, and then it's inside.

  • Um, I'm sorry.

  • We're gonna key words, but title And I think title was under case.

  • Let me confirm.

  • Yeah, okay.

  • Yeah, it looks like it should be under cased or lower case.

  • Rather.

  • Okay, so we have titles now we do want now we want to do keywords.

  • So key words of the string form and again XML and then this one basically the same path.

  • Actually, it's just rather than title, it was keywords.

  • So key words.

  • And then finally, we have the actual locations, so locations don't forget capital l locations.

  • So it does get exported.

  • Um, string and then this one.

  • Stop it.

  • This one is located under XML.

  • And then this one was like it was just your l and then the location and just remember, like one of the location was at the same level as news wasjust news content happens to contain other other tags that we were also interested him.

  • So that's our news struck.

  • Now let's go ahead and go into our main function here now.

  • And basically everything here is good for us.

  • The only difference is basically want to visit now rather than just print out the location we actually want t visit that location instead.

  • So to do that, we would just basically do the exact same thing that we've done, you know, up here.

  • Right?

  • So, um, So what we're gonna do is where we've defined and probably probably you should define your bars, like, at the top here.

  • So it's gonna do that on, then also, bar in news.

  • And then so this will, um, on Marshall in tow s.

  • Then we start iterating through, and then basically, we're just gonna do the exact same thing here, so I'm actually just gonna cop, Actually, let's just copy all three of these lines because we need to do all three of those things.

  • So just paste that in, and then now, rather than HDB get that means site map, what we're gonna do is get the, uh, the location, whatever that happens to be.

  • As we iterated around, um, bites are going to stay the same.

  • And then this time, rather than on marshaling into the site map index we're gonna Unmerciful into our news struck.

  • So now we should wind up with pretty much all that same information that we have.

  • Uh, the only issue now is how we're going to start going through that information.

  • Because at this point, like when we just had locations.

  • Okay, that was just one value.

  • We just lived through that value, and that's all we really wanted to do.

  • But now, in each of these site maps, what we're getting is titled location and Keywords.

  • Well, what do we actually want to do with that?

  • We want to display that on our web app.

  • And so, at least to me, my desire at this point is I want to put this into some sort of key and values system.

  • So in, you know, in python, that would be a dictionary in Django.

  • That's going to be a map.

  • So in the next Victoria, what we're gonna be talking about is how weaken, you know, literate through this and build a map that we can then pass basically to our our Web app.

  • And then we'll use that to display all the information that we want to show on the page.

  • So anyways, that's what we're gonna be doing in the next tutorial.

  • If you have any questions, comments, concerns.

  • Whatever up to this point, feel free living below.

  • Otherwise I will see you in the next tutorial.

What's going on?

字幕と単語

動画の操作 ここで「動画」の調整と「字幕」の表示を設定することができます

B1 中級

Go Webアプリケーションの継続 - Go Lang実践プログラミングチュートリアル p.13 (Continuing our Go Web application - Go Lang Practical Programming Tutorial p.13)

  • 0 0
    林宜悉 に公開 2021 年 01 月 14 日
動画の中の単語