Skip to content

Instantly share code, notes, and snippets.

@animist
Created March 29, 2012 05:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save animist/2233757 to your computer and use it in GitHub Desktop.
Save animist/2233757 to your computer and use it in GitHub Desktop.
test
#!/usr/bin/ruby
puts "id,date,name,url,file,status,position,sort_id,pv,top"
count = 1
whole = 1662
while line = gets
if line.match(/href/)
name = line.sub(/.*>(.*)<\/a.*/, "\\1").chomp
if name.match(/[0-9]+\/[0-9]+:/)
name = name[name.index(":")+1..name.length].gsub('"', '”')
end
date = line.sub(/.*name="([^"]+)".*/, "\\1").chomp
target = line.sub(/.*href="([^"]+)".*/, "\\1").chomp
if target.match(/^http/)
target += ","
else
target = "," + target.sub(/comweb/, "old_files")
end
puts "#{count},#{date},#{name},#{target},2,#{whole - count},1,0,#{count <= 10 ? 1 : 0}"
count += 1
end
end
---
#!/usr/bin/ruby
puts "id,name,url,file,description,sort_id,pv,code,user,section,email,flag,created_at"
count = 1
date = ""
while line = gets
if line.match(/href/)
name = line.sub(/.*>(.*)<\/A.*/, "\\1").chomp
if line.match(/^\[/)
date = "2012/" + line.sub(/.*nbsp;([0-9]+) 月([0-9]+) 日.*/, "\\1/\\2").chomp
elsif name.match(/[0-9]+\/[0-9]+: /)
date = "2012/" + name[0..4]
name = name[7..name.length]
end
target = line.sub(/.*href="([^"]+)".*/, "\\1").chomp
if target.match(/^http/)
target += ","
else
target = "," + target.sub(/comweb/, "old_files")
end
puts "#{count},#{name},#{target},,1,0,,旧データ,旧データ,admin_console,0,#{date}"
count += 1
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment