Created
June 17, 2018 03:24
-
-
Save fuji-nakahara/5ec4c9c9bae4d7b2aa183e5430d9d7f7 to your computer and use it in GitHub Desktop.
SF創作講座のある課題について提出された梗概をまとめて1つのファイルに出力する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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