Answer the question
In order to leave comments, you need to log in
Is it possible to parse a page in the background with Rails + Ajax?
Hello. Interested in this question. I'm trying to make an ajax request that will parse the page.
There is a controller for example index and parser. Parser has a create method, for example, with the following code:
require 'open-uri'
require 'nokogiri'
user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.854.0 Safari/535.2"
page = Nokogiri::HTML(open('http://ya,ru', 'User-Agent' => user_agent), nil, "UTF-8")
RuntimeError in ParsersController#create
redirection forbidden: https://google.com/ -> http://google.com
<div class="source hidden" id="frame-source-0">
<div class="info">
Extracted source (around line <strong>#224</strong>):
</div>
<div class="data">
<table cellpadding="0" cellspacing="0" class="lines">
<tr>
<td>
<pre class="line_numbers">
Answer the question
In order to leave comments, you need to log in
I'll answer myself, yes. The jamb was that the wrong line with the address reached.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question