トップページ > プログラム > 2014年03月29日 > iSspUegM

書き込み順位&時間帯一覧

12 位/220 ID中時間01234567891011121314151617181920212223Total
書き込み数0000000000000002100000014



使用した名前一覧書き込んだスレッド一覧
デフォルトの名無しさん
ver2
ver3
プログラミング言語 Scala 10冊目
C++は難しすぎ 難易度:4

書き込みレス一覧

プログラミング言語 Scala 10冊目
233 :デフォルトの名無しさん[sage]:2014/03/29(土) 15:15:02.64 ID:iSspUegM
import java.io.File
import java.net.URL
import org.apache.commons.io.{FileUtils, FilenameUtils}
val urlRe = """(?i)h?ttps?://[\w/:%#\$&\?\(\)~\.=\+\-]+\.(jpg|jpeg|png|bmp)""".r
val imgDir = new File("img")
val encoding = "Shift_JIS"
def エロ画像収集(url: String) = {
if (!dir.exists()) dir.mkdir()
val urls = io.Source.fromURL(url, encoding).mkString.split("\n").map(s => urlRe.findAllIn(s).toList).flatten
val fixedUrls = urls.map(s => if (s.startsWith("ttp")) "h" + s else s)

fixedUrls.par.foreach{ url =>
def recur(n: Int): Unit = {
val name = FilenameUtils.getName(url)
val file = new File(imgDir, + name)
try {
if (!file.exists()) FileUtils.copyURLToFile(new URL(url), file)
} catch {
case e: java.io.FileNotFoundException =>
case e: java.io.IOException =>
if (n < 3) {
java.lang.Thread.sleep(3000)
recur(n + 1)
}
}
}
recur(0)
}
}

def test_エロ画像収集() = エロ画像収集("""http://pele.bbspink.com/test/read.cgi/ascii2d/1394675699/""")
プログラミング言語 Scala 10冊目
234 :ver2[sage]:2014/03/29(土) 15:31:22.62 ID:iSspUegM
import java.io.{File, FileNotFoundException, IOException}
import java.net.URL
import java.lang.Thread
import org.apache.commons.io.{FileUtils, FilenameUtils}
import java.util.concurrent.atomic.AtomicInteger
val urlRe = """(?i)h?ttps?://[\w/:%#\$&\?\(\)~\.=\+\-]+\.(jpg|jpeg|png|bmp)""".r
val imgDir = new File("img")
val encoding = "Shift_JIS"
val count = new AtomicInteger()
def エロ画像収集(url: String) = {
if (!dir.exists()) dir.mkdir()
val urls = io.Source.fromURL(url, encoding).mkString.split("\n").map(s => urlRe.findAllIn(s).toList).flatten
val fixedUrls = urls.map(s => if (s.startsWith("ttp")) "h" + s else s).distinct
fixedUrls.par.foreach{ url =>
def recur(n: Int): Unit = {
val ext = FilenameUtils.getExtension(url)
val file = new File(imgDir, count.incrementAndGet().toString + "." + ext)
try {
if (!file.exists()) FileUtils.copyURLToFile(new URL(url), file)
} catch {
case e: FileNotFoundException =>
case e: IOException =>
if (n < 3) {
java.lang.Thread.sleep(3000)
recur(n + 1)
}
}
}
recur(0)
}
}
def test_エロ画像収集() = エロ画像収集("http://pele.bbspink.com/test/read.cgi/ascii2d/1394675699/")
C++は難しすぎ 難易度:4
481 :デフォルトの名無しさん[sage]:2014/03/29(土) 16:53:38.29 ID:iSspUegM
test
プログラミング言語 Scala 10冊目
236 :ver3[sage]:2014/03/29(土) 23:39:16.57 ID:iSspUegM
import java.io.{File, FileNotFoundException, IOException}
import java.net.URL
import java.lang.Thread
import org.apache.commons.io.{FileUtils, FilenameUtils}
val urlRe = """(?i)h?ttps?://[\w/:%#\$&\?\(\)~\.=\+\-]+\.(jpg|jpeg|png|bmp)""".r
val imgDir = new File("img")
def エロ画像収集(url: String) = {
if (!dir.exists()) dir.mkdir()
val urls = io.Source.fromURL(url, "Shift_JIS").getLines.map(s => urlRe.findAllIn(s)).flatten.toList
val fixedUrls = urls.map(s => if (s.startsWith("ttp")) "h" + s else s).distinct
fixedUrls.par.foreach{ url =>
def recur(n: Int): Unit = {
val ext = FilenameUtils.getExtension(url)
val file = new File(imgDir, url.replaceAll("[^a-zA-Z0-9]","") + "." + ext)
try {
if (!file.exists()) FileUtils.copyURLToFile(new URL(url), file)
} catch {
case e: FileNotFoundException =>
case e: IOException =>
if (n < 3) {
Thread.sleep(3000)
recur(n + 1)
}
}
}
recur(0)
}
}


※このページは、『2ちゃんねる』の書き込みを基に自動生成したものです。オリジナルはリンク先の2ちゃんねるの書き込みです。
※このサイトでオリジナルの書き込みについては対応できません。
※何か問題のある場合はメールをしてください。対応します。