In this video, I want to make five improvements to the program.
The first improvement is besides the title and the description of the news.
We also want to add a link so that the user can click on that link and read more about that particular
news.
That's the first improvement.
The second improvement is we want to show less news because currently there's 100 of them, so perhaps
20 should be better.
The third improvement is we want to show only news in English because currently we have some other languages
here.
For example, this news in Europe.
Fourth improvement.
We want to add the subject to the email.
And fifth, improvements.
We want to have the category more dynamic because currently Tesla is hardcoded here in the URL, so
we might want to also have the possibility to show other topics.
Let's start with the first improvement links.
To add links, you have to go in here where you construct that string.
So we add the title, we add a brick line, we add the description, and then we add two brick lines.
So the two brick lines are between the different news.
But before we add the two lines, we want to add one other break line.
So plus backslash n then plus article.
You like that.
So that should do it.
But let me split this line because it's getting too long.
So there as well.
And I'll try the codes to make sure it works.
And let's check the email.
So there we go.
We have links right now, the language to fix the language issue, you should add a new parameter to
the query.
What is the parameter?
Well, the URL is made of different parts.
It does have the code part first, which is this one in here.
So let me show you the complete URL first as it was in the beginning without splitting it across multiple
lines.
So that's the complete URL.
Now this is a core part up to here.
So everything question mark.
Then we have the parameters.
So this here is a parameter.
Q is the name of the parameter and Tesla is the value.
And then we have this symbol which separates the parameters from each other.
So we have the sort by parameter which defines how the news will be sorted.
And so these are sorted now by published date.
And then we have this symbol again to separate the other parameter from the previous one.
We have the API key, the name of the parameter and the value, which is this value here of the API
key.
Now we can add all the parameters of the end here.
You want to write the end symbol and then language is equal to n.
So the parameter name and the value which is English.
So that's also a parameter of this API.
And you can find the parameters of this particular API in the news API dot org website.
If you go to documentation.
And you go to the end points and you go to the everything and points.
And here you should find all the names for the parameters.
So language is one of the parameters and you can pass these languages there.
So we have sorted by as well.
And other parameters, too.
Q Which defines the topic, which is currently set to Tesla.
So now let me prove the view here.
So I'll split the string.
And the parameters here and the next parameter after the symbol and the next one after the symbol.
So this makes more sense.
It's more readable, I think.
So if I run this code now.
And I check the email again.
I should now see only news in English.
Yep, that's the case.
So it's seems to be working.
So let's go back and let's limit the emails to 20 only four.
That's all we have to do is go to contents article.
So this is a list we're iterating over a list here.
And this list has 100 items.
But if you use this list, indexing.
Sorry.
It has to be the first 20.
So 0 to 20 or just up to 20 the same.
This now should give us only about 20 emails.
Let's see.
Yeah, it's about 20.
So that's fewer news.
Next.
The subject and the subject of the email is part of the body of the email.
So as you might remember from the previous email lectures in the previous apps, we used to add the
subject on top of message of the email body.
So that would be subject a column, a space, and then write something for the subject such as today's
news Plus.
A backslash, an operator, because that's the syntax.
So the message should be something like.
Subject to these.
News.
And then we have a brake line and there goes the body of the email, which is the news.
So news number one, news number two, etc..
So you get the idea, I suppose, and I'll split the line in here and try out the code.
Let's see.
That's where the subject is.
So it's working.
Everything seems to be looking fine.
Lastly, the last change I want to make to this code is to fix the heart coding issue.
So when something is injected into a value, for example, here, Tesla is part of this string that
is known as hardcoded.
So this is an hardcoded value to make this more dynamic.
We could create a variable here, let's say topic and then you say Tesla here and then you convert this
into an EV string and instead of Tesla there you have a placeholder and then you write a topic there.
But be careful here because this string is spread across multiple lines.
So actually the F should be at the line where the placeholder is located.
So it should be in here.
So with that, you can run the script.
And check the email.
And yeah, there we go.
That's still news about Tesla.
So it's working fine.
So that gives us some more control over what we want to display here.
So it's better to change the the variable name in here instead of modifying the value of the string
itself.
So with that, we have done all the five improvements, so we are ready to commit the changes.
So that's the 28.
And you might want to mention here all the improvements add links.
Specify language limits use.
At subject.
And control the category.
Now it's a better idea to actually make a commit.
So whenever you want to make one single change.
So in this case, it would be better if we added the links as we did here.
So after we did this change, we should have committed the changes and then we did the other change
and we commit the other change.
And in each commit message we only write that particular change that we did.
However, I'm not doing that because it would be too much for doing it in a video.
Those would be too many pauses.
So that's something to keep in mind.
You want to commit whenever you make a change and then you test the program.
If it's working and if it's working, then you commit.
Yeah.
So let's commit.
And that's for this video.
Thank you for following.