Skip to content

Instantly share code, notes, and snippets.

@fuji-nakahara
Created June 17, 2018 03:24
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 fuji-nakahara/5ec4c9c9bae4d7b2aa183e5430d9d7f7 to your computer and use it in GitHub Desktop.
Save fuji-nakahara/5ec4c9c9bae4d7b2aa183e5430d9d7f7 to your computer and use it in GitHub Desktop.
SF創作講座のある課題について提出された梗概をまとめて1つのファイルに出力する
require 'open-uri'
require 'nokogiri'
KADAI_URL = 'http://school.genron.co.jp/works/sf/2018/subjects/1/'
doc = Nokogiri::HTML(open(KADAI_URL))
urls = subject_doc.css('.student-list .written a').map { |e| e['href'] }
kougais = urls.each { |url| Nokogiri::HTML(open(url)).at_css('.summary-content').content }
File.write('kougai.txt', kougais.map { |kougai| kougai.sub(/文字数:\d+\s*\Z/, '').strip }.join("\n\n"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment