Scrapy, why can both return and yield operate?

has been distributed recently, but both yield and return can return data when crawling. Why?
ask for advice

tags.append (tag ["name"])

item["tags"] = ",".join(tags)
item["fullName"] = companyData["fullName"]
item["scale"] = companyData["scale"]
asTs, asEncryptedTs = execjs.compile(self.js_read).call("p")
kw_url = "https://rong.36kr.com/n/api/search/company?asEncryptedTs={}&asTs={}&kw={}&sortField=MATCH_RATE".format(
    asEncryptedTs, asTs, item["name"])

retunr scrapy.Request(
    url=kw_url,
    callback=self.get_kw_info,
    dont_filter=True,
    meta={"id": response.meta["id"], "item": item},
)

def get_kw_info (self, response):

item = response.meta["item"]
pageData = json.loads(response.text)["data"]["pageData"]["data"]
industryStr = pageData[0]["industryStr"]
item["industryStr"] = industryStr
asTs, asEncryptedTs = execjs.compile(self.js_read).call("p")
finance_link = "https://rong.36kr.com/n/api/company/{}/finance?asEncryptedTs={}&asTs={}".format(
    response.meta["id"], asEncryptedTs, asTs)
retun scrapy.Request(
    url=finance_link,
    callback=self.get_finance_info,
    dont_filter=True,
    meta={"id": response.meta["id"], "item": item})

does this code always return data from both yield and return? Why is that?

Feb.04,2022

this question is actually the difference between yield and return , return need not say much, certainly understand. So the question becomes what yield is.

you may need to understand what a generator is before entering the text, and you need to understand what iteration is before a generator.

< H1 > iteration < / H1 >

if a list, it is an iterable object, called Iterable in Python.

In [15]: def foo():
    ...:     _list = range(4)
    ...:     print('run in func')
    ...:     for i in _list:
    ...:         print('run in loop')
    ...:         yield i
    ...:
    ...:

In [16]: gen = foo()

In [17]: for i in gen:
    ...:     print(i)
    ...:
    ...:
run in func
run in loop
0
run in loop
1
run in loop
2
run in loop
3

so you should understand the difference between return and yield in Scrapy ~

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3e42c-2c411.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3e42c-2c411.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?