2015-04-16 59 views
1

嗨完全在本地主机,但部分工作,我有一些奇怪的事情发生:引入nokogiri解析在Heroku

我的应用程序有以下控制措施:

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 

要呈现以下几种观点:

<%= @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> 

一切工作正常,但在Heroku只有<%= @show%>工作。在Heroku <%= @game_data%>似乎是空的,而不应该是。

我无法弄清楚什么是错的,你的帮助是完全赞赏的。

<tbody>从网站(从HTML文本翻译):

足球欧洲 - 法甲德 champions1N2弥 temps21艾薇2015年 - 20:45Bayern慕尼黑 - Porto2.632.657.5010.91%

截图:

enter image description here

回答

3

问题是,该网站在美国不会产生与法国相同的内容。

由于我位于法国,它在当地有效,但在Heroku(美国)则没有。

此问题导致我to another question

+0

太棒了!我删除了我的回答和我的评论。你也应该这样,他们很吵,因为这个答案最好地描述了解决方案。 –

+0

你是对的;-) – Antoine