【发布时间】:2018-04-06 23:06:24
【问题描述】:
寻求帮助以帮助我入门。我正在尝试从这个网站上抓取最新的游戏信息:
https://www.pinnacle.com/en/odds/match/soccer/england/england-premier-league
我真的在为使用 Nokogiri 提取代码的语法而苦苦挣扎。我见过并尝试过的所有示例都使用比这更简单的站点!
如果我有:
class BdcController < ApplicationController
def bdc
require 'nokogiri'
require 'openssl'
doc = Nokogiri::XML.parse(open('https://www.pinnacle.com/en/odds/match/soccer/england/england-premier-league?sport=True', :ssl_verify_mode => OpenSSL::SSL::VERIFY_NONE))
hometeam = doc.css('table.odds-data.game-name name').text #no idea what this line shoudl be to return e.g the first team in the list (currently Leicester City)
end
@grab=hometeam
end
它目前返回 nil(这并不奇怪,因为我无法确定主队阵容应该是什么样子!)
谁能给我一个例子,说明主队的首发阵容应该读什么?提前致谢!
TD
【问题讨论】: