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,数据被挖掘出来。
- How do I implement this into a Rails application?
- Do I put my code into a controller?
- Does Nokogiri work in controllers?
- Do I need to require Nokogiri?
- Do I use a Rake task?
- 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.
如何将其实现到Rails应用程序中?
我将代码放入控制器吗?
Nokogiri是否在控制器中工作?
我需要要求Nokogiri吗?
我是否使用Rake任务?
如果我使用Rake任务,如何将用户提交的URL放在Rake任务中?我读过以前的SO帖子(不知道在哪里)从控制器执行Rake任务是一个很大的安全禁忌。
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.
- Works in controllers? Yes.
- Require Nokogiri? Yes.
- Rake tasks? Probably no.
投入控制器?您可以将代码放入控制器,这意味着它的同步和用户必须等到解析完成。
在控制器中工作?是。
要求Nokogiri?是。
耙任务?可能没有。
You may want to checkout things like Resque.
您可能想要查看Resque等内容。
#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.
- Works in controllers? Yes.
- Require Nokogiri? Yes.
- Rake tasks? Probably no.
投入控制器?您可以将代码放入控制器,这意味着它的同步和用户必须等到解析完成。
在控制器中工作?是。
要求Nokogiri?是。
耙任务?可能没有。
You may want to checkout things like Resque.
您可能想要查看Resque等内容。