Item by plane.
Hello, guys.
Today, we're going to talk about pipelines and the easiest way to explain why this pipeline is if you
imagine that after an item has been scrapped by the spider, it is immediately sent to the pipeline,
which produces a fight with several components.
So each pipeline component is actually a patent class that implements a simple metals.
So the pipelines basically receive an item and perform an action over it.
And they won't have the function and the option to decide if the item either has to continue through
the pipeline or actually be dropped away.
OK, so they have some mechanism over them, but we're going to show this in that video for sure.
So the pipelines are usually used to clean HTML data who also validate scrub data.
So if you don't want to scrub data, they would usually validate if the data you have is the correct
one, they would also check for duplicates or they can simply store an item scrap item in the database.
So let me actually show you how we can write your own pipelines.
So, guys, if you have a look at the project that we created earlier and if you select here pipelines,
you can see that the current pipeline is quite simple and it's represented by class.
So obviously we can change that pipeline to the following.
So let's try it from scrapie, dot exceptions, import drop item, OK, and then instead of diskless,
we can create another one.
So class and I would delete this item adapter from here so you can create a class called Price Pipeline.
OK.
And then hero, right object.
OK, so here I will write about.
Factor to be equal to one point one five.
OK, then let's try the due process item.
So this will be the function and let's right.
Let's pass the function item and spider, OK, and then if item price.
OK, so if the item to price and if item price.
Excludes.
What?
OK.
Item price equals item and then price multiplied by itself and thought, what factor?
OK, so.
So this basically means that if the price of the item is excluding the VAT, we'll need to multiply
it by one point one five.
Twatt, this tax.
OK, this is the whole idea that the return item.
OK, and let's right.
Else raise and then drop item and here we are.
Right.
Missing price in percent as in on the place of the percentage who plays the actual item.
OK, so obvious to hear.
If we get different price from what we need, we're going to process it and display the actual price
we need.
So imagine if you're shopping and you want to extract information about item prices.
And if you detect an item that is that is written with price excluding VAT, you always want to multiply
it by one point one five.
In order for you to be able to display the actual price of the item.
So in the end, you have a good sheet with all the prices and you know that all of them are with the
VAT factor.
So this was all I want to share with you guys about the pipelines and what is the whole purpose of those
pipelines.
So that said, thank you very much for watching.
I hope you use them very well, although they are not that commonly used when describing objects for
some projects, you might need them, but is very good to know about their existence.
So you are able to decide whether you need them or not.
That's it.
Thank you very much for watching and I'll see you in the next video.