Antoine
Antoine

Reputation: 569

Nokogiri parsing working fully on localhost but partially on heroku

Hi I have something weird happening:

My app has the following controller action:

def test

  #get URL
  url = "http://www.coteur.com/surebet.php"
  doc = Nokogiri::HTML(open(url))
  @show = doc.at_css("title").text

  @game_data = Array.new
  doc.css('tbody').each do |tr|
    tr.css("tr").each do |f|
      @game_data.push(f.css("td").text)
    end
  end

end

To render the following view:

<%= @show%>
<div class="bs-example" data-example-id="hoverable-table">
  <table class="table table-hover">
    <tbody>
      <% if @game_data.empty? %>
        <tr>
          <td>Nope</td>
        </tr>
      <%else%>
        <% @game_data.each do |game|%>
          <tr>
            <td><%= game%></td>
          </tr>
         <%end%>
      <%end%>
    </tbody>
  </table>
</div>

Everything work fine locally but on Heroku only the <%= @show%> work. On Heroku the <%= @game_data%> appears to be empty while it should not be.

I cannot figure out what is wrong, your help is fully appreciated.

Inside <tbody> from the site (translated in text from html):

Football Europe - Ligue des champions1N2 Mi temps21 Avril 2015 - 20:45Bayern Munich - Porto2.632.657.5010.91%

Screenshot:

enter image description here

Upvotes: 1

Views: 116

Answers (1)

Antoine
Antoine

Reputation: 569

The problem is that the website does not generate the same content in the US as in France.

As I'm located in France, it works locally, but on Heroku (US) it does not.

This problem lead me to another question.

Upvotes: 3

Related Questions