简体   繁体   English

将数据从 Scrapy 推送到 .Net 应用程序的最佳方法

[英]Best Method to Push Data from Scrapy to .Net Application

Best Method/Idea to push scraped data from Scrapy crawlers to .Net Application将抓取的数据从 Scrapy 爬虫推送到 .Net 应用程序的最佳方法/想法

Setup:设置:

  1. Debian server runs a scrapy server Debian 服务器运行一个scrapy 服务器
  2. Windows server run a .Net Core application server Windows 服务器运行 .Net Core 应用程序服务器

I am thinking about adding a RESTful API to my .Net Core Service and push item data there from Scrapy on every crawler "finished" event.我正在考虑向我的 .Net Core 服务添加一个 RESTful API,并在每个爬虫“完成”事件上从 Scrapy 推送项目数据。

Basically I want to have kind of "push-notifications" from Scrapy server to my .Net app when new data item is scraped.基本上,当新数据项被抓取时,我希望有一种从 Scrapy 服务器到我的 .Net 应用程序的“推送通知”。

What is the best place to put that call to an external API in scrapy?在scrapy中调用外部API的最佳位置是什么?

You have multiple options here.您在这里有多种选择。 Pushing data is indeed the easiest solution, though make sure to authorize the requests you make to your API.推送数据确实是最简单的解决方案,但请确保授权您向 API 发出的请求。 You can use the item_scraped signal to invoke your requests for every scraped item.您可以使用item_scraped 信号来调用您对每个已抓取项目的请求。 Keep in mind that in case there are hundreds of scraped items, it might put a lot of stress on your API which is something you should avoid.请记住,如果有数百个被抓取的项目,它可能会给您的 API 带来很大压力,这是您应该避免的。 You can wait until the scraper has finished and then invoke your API with a single request.您可以等到刮板完成,然后通过单个请求调用您的 API。 Some alternative solutions:一些替代解决方案:

  • Put scraped items in your database and poll the database for new items in the other application将抓取的项目放入您的数据库中并轮询数据库中其他应用程序中的新项目
  • Use a messaging queue like RabbitMQ, AWS SQS or Kafka使用消息队列,如 RabbitMQ、AWS SQS 或 Kafka

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将更改数据从sql server推送到Windows / Web应用程序的最佳方法 - Best way to push change data from sql server to windows/web application 在.net Core应用程序中从数据库(实体框架或Ado.Net)获取数据的最佳方案是哪一种? - Which is the best Scenario for getting data from Database (Entity Framework or Ado.Net) in a .net Core application? 将数据从Sql Server推送到桌面应用程序 - Push data from Sql Server to desktop application 如何将MySQL数据库数据推送到MVC .NET Web应用程序 - How to push MySQL Database Data to a MVC .NET web application 如何从Windows Phone 7向.NET Winform应用程序发送推送通知 - How to send a Push Notification from windows Phone 7 to .NET Winform Application 在.Net应用程序中保存/加载大量数据的最佳方法? - Best way to save/load large amout of data in a .Net application? .NET - 在桌面应用程序中存储加密离线数据的最佳方式 - .NET - Best way to store encrypted offline data in Desktop Application .net应用程序中的Web api异步方法 - web api asynchronous method from .net application 从桌面应用程序操作MySQL数据库的最佳方法是什么? - What is the best method of manipulate a MySQL database from a desktop application? 从 .Net 框架应用程序中的 .Net Core 库调用方法 - Invoke method from .Net Core library in .Net framework application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM