use the send_message and on_message methods to handle situations where multiple task results are returned from a single page, and prepare to override the on_result method for further processing. However, the msg returned by the on_message method is not passed to on_result, that is, result is None.
I don"t know what to do with it. Thank you.
@config(age=10 * 24 * 60 * 60)
def index_page(self, response):
response.encoding = "GBK"
print(response.doc("title").text())
for i, each in enumerate(response.doc(".newstable tr").items()):
msg = dict()
msg["title"] = each("td:nth-child(1) a").attr("title").strip()
msg["date"] = each("td:nth-child(2)").text().strip()
msg["link"] = each("td:nth-child(1) a").attr("href")
self.send_message(self.project_name, msg,
url="{}.false".format(msg["link"]))
def on_message(self, project, msg):
return msg
def on_result(self, result):
print(result)