#解析rubyer.me的首页所有文章的标题
require 'nokogiri'
require 'open-uri'
website_url = "http://www.rubyer.me"
STDERR.puts "processing #{website_url}..."
doc = Nokogiri::HTML(open(website_url))
path = "/html/body/div/div/div/article/header/h1/a"
topics = doc.xpath(path)
topics.each { |t|
puts t.content
}
用nokogiri解析网页
最新推荐文章于 2024-03-18 09:37:08 发布