<form method="post" action="/M740/Biography/History/Drama/12+Years+a+Slave">
<input type="image" src="/public_site/webroot/cache/imdb/2024544_100.jpg" width="100" style="float:right;margin-left:2px;">
<strong><span style="color: rgb(255, 69, 0);">12 Years a Slave</span></strong>
<br>
In the antebellum United States, Solomon Northup, a free black man from upstate New York, is abducted and sold into slavery.<br>
<br><strong>Century Cinemax - Junction</strong><br>
<a href="tel:0774136246">0774136246</a>
<a href="tel:0208022073">0208022073</a>
<br>
12:10, 19:10, 21:40<br>
<br><strong>Fox Cineplex Sarit</strong><br>
<a href="tel:0203753025">0203753025</a>
<a href="tel:0720366208">0720366208</a>
<br>
11:00, 14:00, 18:00, 20:40<br>
<br><strong>Planet Media - Kisumu </strong><br>
<a href="tel:0731999100">0731999100</a>
<a href="tel:0724999100 & 0202629388">0724999100 & 0202629388</a>
<br>
12:00, 14:30, 20:30<br>
<br>
<input type="hidden" name="cinema" value="0">
<input type="hidden" name="searchMovie" value="0">
<input type="hidden" name="movie" value="740">
<input type="hidden" name="date" value="0">
<input type="hidden" name="groupId" value="0">
<input type="submit" name="ok" value="Further Details">
</form>
好吧,這只是我試圖解析使用Nokogiri的一部分HTML。 html中的語義並不完整,我正在用Nokogiri獲得想要的內容。作爲參考,這是我想要廢除的網站(http://flix.co.ke/Frontpage/Listings)解析內容不在html標籤Nokogiri
到目前爲止,我能夠獲得電影的標題,一個電影院和兩個電話號碼,但與我的方法我不能真正得到所有內容所需
這是我使用
require 'rubygems'
require 'nokogiri'
require 'open-uri'
url = "http://flix.co.ke/Frontpage/Listings"
doc = Nokogiri::HTML(open(url))
doc.css(".min-width div form").each do |entry|
title = entry.at_css("span").text
puts title
cinema = entry.at_css("br+ strong").text
puts cinema
phone = entry.at_css("a").text
puts phone
puts entry.at_css("a").next_element.text
end
有了這個我目前的劇本我只能夠得到電影的title
,one cinema
和two contact numbers
所以我的樣本輸出的模樣。
12 Years a Slave
Century Cinemax - Junction
0774136246
0208022073
47 Ronin 3D
Century Cinemax - Junction
0774136246
0208022073
Delivery Man
Century Cinemax - Junction
0774136246
0208022073
Frozen
Century Cinemax - Junction
0774136246
0208022073
(continued...)
有,只是在休息標記後稱號後的描述,我無法得到這一點,並我怎麼通過
標籤內的所有電影院循環?以及逗號分隔的電話號碼和個人演出時間。
我只是不知道從哪裏開始。我會想取得這樣的成績對於這種情況
12年從
在戰前美國,所羅門·諾薩普,一個自由的黑人男子從紐約州北部,被綁架並賣入奴隸制。
- 世紀Cinemax的 - 結 12:10,19:10,21:40
- 福克斯影城沙立 11:00,14:00,18:00,20:40
etc
任何幫助將不勝感激。在此先感謝
包含有效的HTML片段,而不是提取。爲了幫助你,我們必須跳過籃球。 –