-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.rb
37 lines (33 loc) · 878 Bytes
/
app.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require "sinatra"
require "feedalizer"
require "time"
require "kconv"
require "haml"
get '/' do
haml :index
end
get "/news" do
begin
url = "http://zozo.jp/news/"
rss = feedalize(url + "list_order.html") do
feed.title = "ZOZOTOWN NEW!"
feed.about = "zozotown"
feed.description = "ZOZOTOWN"
scrape_items("div.listOrderBox ul.cf li") do |item, li|
a = (li/"dl dd div.label a").first
date = Time.parse( "20" + (li/"p.date").first.inner_html)
item.link = url + a.attributes['href']
item.date = date
item.title = a.inner_html.toutf8.strip
content = li.inner_html.toutf8
content.gsub! /\?w=[0-9]+&h=[0-9]+/, ""
content.gsub! /(width|height)="[0-9]+"/, ""
item.description = content
end
end
content_type :rss
rss.output
rescue => e
"Error"
end
end