require "net/http"
require "rexml/document"
uri = 'http://www.beijingaqifeed.com/shanghaiaqi/shanghaiairrss.xml'
html_response = Net::HTTP.get_response(URI.parse(uri)).body
doc = REXML::Document.new(html_response)
description = doc.elements["rss/channel/item/description"].text
puts description
写过的第二个ruby脚本,第一个当然是hello world
本文介绍了一个简单的Ruby脚本,该脚本用于从指定的RSS源中抓取空气质量信息。通过使用Net::HTTP和REXML库,它可以轻松地获取并解析上海的空气质量报告。
920

被折叠的 条评论
为什么被折叠?



