通过Nokogiri显示数据的正确方法是什么?

时间:2021-02-13 19:44:20

In my application I have a field where users can enter a URL and then products will be scraped from that URL. I watched "Screen Scraping with Nokogiri", and I created the result I wanted; I put in a URL and the data gets mined.

在我的应用程序中,我有一个字段,用户可以在其中输入URL,然后从该URL中删除产品。我看了“用Nokogiri进行屏幕刮擦”,我创造了我想要的结果;我输入了一个URL,数据被挖掘出来。

  1. How do I implement this into a Rails application?
  2. 如何将其实现到Rails应用程序中?

  3. Do I put my code into a controller?
  4. 我将代码放入控制器吗?

  5. Does Nokogiri work in controllers?
  6. Nokogiri是否在控制器中工作?

  7. Do I need to require Nokogiri?
  8. 我需要要求Nokogiri吗?

  9. Do I use a Rake task?
  10. 我是否使用Rake任务?

  11. If I do use a Rake task, how do I put the user-submitted URL in that Rake task? I read on a previous SO post (not sure where) that executing Rake tasks from the controller is a big security no-no.
  12. 如果我使用Rake任务,如何将用户提交的URL放在Rake任务中?我读过以前的SO帖子(不知道在哪里)从控制器执行Rake任务是一个很大的安全禁忌。

1 个解决方案

#1


1  

  1. Put into controller? You can put your code into a controller, which means its sync, and user, have to wait until parsing is completed.
  2. 投入控制器?您可以将代码放入控制器,这意味着它的同步和用户必须等到解析完成。

  3. Works in controllers? Yes.
  4. 在控制器中工作?是。

  5. Require Nokogiri? Yes.
  6. 要求Nokogiri?是。

  7. Rake tasks? Probably no.
  8. 耙任务?可能没有。

You may want to checkout things like Resque.

您可能想要查看Resque等内容。

#1


1  

  1. Put into controller? You can put your code into a controller, which means its sync, and user, have to wait until parsing is completed.
  2. 投入控制器?您可以将代码放入控制器,这意味着它的同步和用户必须等到解析完成。

  3. Works in controllers? Yes.
  4. 在控制器中工作?是。

  5. Require Nokogiri? Yes.
  6. 要求Nokogiri?是。

  7. Rake tasks? Probably no.
  8. 耙任务?可能没有。

You may want to checkout things like Resque.

您可能想要查看Resque等内容。