• R/O
  • SSH
  • HTTPS

shm-rss: Commit


Commit MetaInfo

Révision2 (tree)
l'heure2014-05-08 11:15:22
Auteurtamomo

Message de Log

Add README

Change Summary

Modification

--- trunk/shm.rb (revision 1)
+++ trunk/shm.rb (revision 2)
@@ -3,12 +3,17 @@
33 require 'open-uri'
44 require 'rss'
55
6-url = "http://www.st.ryukoku.ac.jp/~kjm/security/memo/"
6+debug = true if ARGV[0] == "-d"
7+
8+url = 'http://www.st.ryukoku.ac.jp/~kjm/security/memo/'
9+url = './index.html' if debug
10+puts "opening #{url}" if debug
711 doc = Nokogiri::HTML(open(url))
812
913 ### FIXME: any better ways there?
1014 doc.css('a[href^="/~kjm/"]').each do |anc|
11- anc['href'] = "http://www.st.ryukoku.ac.jp" + anc['href']
15+ anc['href'] = 'http://www.st.ryukoku.ac.jp' + anc['href']
16+ puts "prefixed: #{anc['href']}" if debug
1217 end
1318
1419 ### Which version should we use?
@@ -16,9 +21,11 @@
1621 xml.channel.title = doc.title
1722 xml.channel.link = url
1823 xml.channel.description = doc.css('div.NORMAL').first.children
24+ p xml.channel if debug
1925
2026 doc.css('a.NU').each do |link|
2127 next if link.parent.name == "h2"
28+ puts "processing: #{link}" if debug
2229 i = xml.items.new_item
2330 ### a"》", span" ", content
2431 i.title = link.next.next.content
@@ -27,12 +34,19 @@
2734 ### Normal short items
2835 i.description = link.parent.parent.children
2936 elsif link.parent.name == "h3"
30- ### "various" etc
37+ ### "various", "tuiki" etc
3138 i.description = link.parent.next.next
3239 else
3340 i.description = "Something wrong"
3441 end
3542 i.date = Time.parse(/#([0-9]{8})/.match(link['href'])[1])
43+
44+ if debug
45+ puts " #{link.parent.name}: Title: #{i.title}"
46+ puts " Link: #{i.link}"
47+ puts " Date: #{i.date}"
48+ puts "" ### description is too long to put here
49+ end
3650 end
3751
3852 ### TTL depends on your cron settings
@@ -39,6 +53,7 @@
3953 xml.channel.ttl = "60" ### (in minutes)
4054 end
4155
56+### Lazy: should check before writing
4257 File.open("shm.rss", "w") do |f|
4358 f.write(rss.to_s)
4459 end
--- trunk/Makefile (nonexistent)
+++ trunk/Makefile (revision 2)
@@ -0,0 +1,10 @@
1+all:
2+ @echo "Nothing to make. See README"
3+
4+test: index.html
5+ ruby shm.rb -d
6+ @echo "Examine shm.rss manually"
7+
8+index.html:
9+ wget "http://www.st.ryukoku.ac.jp/~kjm/security/memo/index.html"
10+
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
--- trunk/README (nonexistent)
+++ trunk/README (revision 2)
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Afficher sur ancien navigateur de dépôt.