简体   繁体   中英

Ruby on Rails Pulling Information From Another Site

我有一个ruby on rails项目,我必须在其中做一个新闻页面,但我不只是想将文章放在数据库中(这将花费很长时间),无论如何,您都可以从另一个站点提取信息并显示它在您自己的网站上。

This is quite a broad question.

Depending on whether the web applications that you're getting your data from have APIs or not, you would either use those to retrieve the data or you'd have to web scrape it.

For accessing an API you could use Net:HTTP or HTTParty or similar. For web scraping you'd want to use similar libraries for retrieving the page and some parser like Nokogiri to parse the HTML. In both cases you'd want to store the results in your own database to avoid having to scrape/query API upon every request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM