Created
June 6, 2012 13:32
-
-
Save orangeclover/2881874 to your computer and use it in GitHub Desktop.
PARTAKEから申込者のアイコンをダウンロードし、座席表用のアカウントつき画像を作成する座席表職人のためのGroovyスクリプト
This file contains hidden or 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
| @Grab("net.sourceforge.nekohtml:nekohtml:1.9.14") | |
| import groovy.swing.j2d.* | |
| import javax.imageio.*; | |
| import org.cyberneko.html.parsers.SAXParser | |
| /** | |
| * Created with IntelliJ IDEA. | |
| * User: orangeclover | |
| * Date: 12/06/06 | |
| * Time: 20:51 | |
| * To change this template use File | Settings | File Templates. | |
| */ | |
| if (!args || args.size() !=1) { | |
| println "usge:groovy Kokucheese.groovy http://partake.in/events/XXXX-XX-XXX-XXXXX" | |
| System.exit(1) | |
| } | |
| def parser = new XmlSlurper(new SAXParser()) | |
| def html = parser.parse(args[0]) | |
| def rows = html.'**'.find { it.@class == 'event-participants rad' } | |
| def listFile = new File("list.txt").newWriter() | |
| def imgUrl = "" | |
| def id = "" | |
| rows.UL.LI.'**'.each{ | |
| if(it.name() == 'IMG' && it.@class == "userphoto"){ | |
| imgUrl = it.@class.@src.toString() | |
| } | |
| if(it.name() == 'A') { | |
| id = it.text().trim() | |
| } | |
| if (imgUrl != "" && id != "") { | |
| try { | |
| img = ImageIO.read(imgUrl.toURL()) | |
| gr = new GraphicsRenderer() | |
| gr.renderToFile("@${id}.png", img.width + 100, img.height + 20){ | |
| antialias("on") | |
| image(image: img, x:0,y:0) | |
| font(new java.awt.Font('Tahoma', java.awt.Font.BOLD, 15)) | |
| text( x:0, y:img.height + 5, text: "@${id}", borderColor: no, fill: 'blue') | |
| } | |
| listFile.writeLine("[twitter:@${id}]") | |
| } catch (Exception e) { | |
| listFile.writeLine("\t${id} 例外発生:" + e) | |
| } | |
| imgUrl = "" | |
| id = "" | |
| } | |
| } | |
| listFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment