【问题标题】:Having multiple fields from my scrape从我的抓取中获得多个字段
【发布时间】:2013-10-17 09:12:42
【问题描述】:

我用 nokogiri 做了一个屏幕截图,看起来像这样。在我的团队模型中

      def pull_teams
        url = "http://www.nba.com/standings/team_record_comparison/conferenceNew_Std_Cnf.html"
        doc = Nokogiri::HTML(open(url))
        doc.css("tr.title:has(td:contains('Western')) ~tr").map do |team|
          team.search('td')[0].text
        end
      end

我已经得到了

    require 'nokogiri'
    require 'open-uri'

也在里面。

我已经在我的团队控制器中得到了这个

      def new
        @team = Team.new
        @team.refresh_teams
      end

在我看来我有这个

<% @teams.each do |team| %>
          <tr>
            <td><%= link_to team.name, team %></td>
            <td><%= link_to 'Destroy', team, method: :delete, data: { confirm: 'Are you sure?' } %></td>
            <td><%= link_to 'edit', edit_team_path(team) %></td>
            <% end %>

我希望能够在桌面上发布团队名称和其他所有内容,如果它有助于我的 git 在这里?

谢谢

【问题讨论】:

    标签: ruby-on-rails ruby screen-scraping


    【解决方案1】:

    td里面放一个循环

    doc.css("tr.title:has(td:contains('Western')) ~tr").map do |team|   
      team.search('td').map do |v|
        <td><%=v.text%><td>
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-28
      • 1970-01-01
      • 1970-01-01
      • 2016-01-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多