Spider in Scrappy

Can you please explain this line?

yield scrapy.Request(url=url,callback=self.parse)

What is this line of code doing, what is it returning, what is callback here, and how is parse called here?

Here is the full code, for your reference-

hey @LPLC0059 ,

Yield is special kind of return function . When using return we need to complete 100% of the task after that only we can pass on the value , but there are some times when we need to give outputs interactively in a synchronous manner , mean whenever we retirieve the data , we just pass it to our worker and let the previous code keep retrieving the data ,just like multiprocessing.
What this line do is, it gets the data from url ( in html format ) and pass it to self.parse function to process or parse it for further usage.

It’s returning a parsed content from the url.

callback is kind of function used to complete a routine or procedure. here it is used to parse the data retrieved from url.

It is something a kind of internal working. The scrapy function calls this parse variable function to complete its task and provide you with a useful information.

I hope this would have helped You.
Thank You :slightly_smiling_face:.