Answer the question
In order to leave comments, you need to log in
I am learning Ruby on Rails. The question arose. Is it possible to somehow read the contents of an external web page, parse it and write the necessary data to the database?
As I understand it, some controller should be responsible for this. But there are no ideas at all how to describe it correctly.
Answer the question
In order to leave comments, you need to log in
Can.
You can parse in different ways. The most popular is nokogiri .
Usually such things are done in background tasks ( ActiveJob ) using, for example, services .
The Ruby on Rails framework has other goals.
It is enough to use only Ruby and some libraries:
https://www.ruby-toolbox.com/categories/html_parsing
https://www.ruby-toolbox.com/categories/http_clients
https://www.ruby-toolbox.com/ categories/orm
https://www.ruby-toolbox.com/categories/Background_Jobs
As I understand it, some controller should be responsible for this.No, page parsing is a long-term action, so you pass this to the model through the controller, the model puts the address in the queue, and a separate worker will already parse.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question