R
R
Ramses6662018-04-11 00:04:44
Ruby on Rails
Ramses666, 2018-04-11 00:04:44

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

3 answer(s)
B
blackst0ne, 2018-04-11
@Ramses666

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 .

R
Roman Mirilaczvili, 2018-04-12
@2ord

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

O
OnYourLips, 2018-04-11
@OnYourLips

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 question

Ask a Question

731 491 924 answers to any question