Groovyでoutputzの文字数を取得する(改行の改造版)


Groovyで改行コードを扱う方法を元に改行の処理を追加。

@Grab('net.sourceforge.htmlunit:htmlunit:2.8')

import com.gargoylesoftware.htmlunit.WebClient


MAGIC_WORD="?????"  //outputz の復活の呪文


webClient = new WebClient()
configPage = webClient.getPage('http://outputz.com/config/')
form =configPage.getForms()
field = form[0].getInputByName('magic_word')
field.setValueAttribute(MAGIC_WORD)
button = form[0].getInputByValue('register')
result = button.click()


yesterday = (new Date() -1).format("yyyyMMdd")
dailyPage = webClient.getPage("http://outputz.com/daily/${yesterday}")

/* ex <span>1,987</span>bytes</p>  */
span = dailyPage.getByXPath("id('contentBox')/div[1]/p")[0]

/* ex 1,987 bytes */
text = span.asText()
/* ex 1,987→1987 */
dailyByte =( text.split()[0] =~ /,/).replaceAll("")



record = (new Date() -1).format("yyyy-MM-dd") + ",${dailyByte}\n"
println record

file = new File("C:\\usr\\var\\outputz\\outputz.txt")
file.append(record.denormalize())

気になるモノ




ベッドやソファに簡単に差し込むだけで収納ラックになる新しい発想のラックが登場!座ったまま、寝たまま、リモコンがすぐ見つかる!

あなろ(インテリア雑貨)

¥ 980 (税込、送料別)

価格は記載時点のものです。購入前にご確認ください。