wshã¹ã¯ãªããä½æç¨ã®ãã³ãã¬ã¼ããä½ã£ã
ãã¦ã³ãã¼ã
http://kasei-san.sakura.ne.jp/wsh/wshScriptTemp.js
ã©ã¤ã»ã³ã¹ã¯ãNYSLã§ãé¡ããã¾ãã(è¦ã¯ããªã¼ã§ã)
ããã¯ä½ï¼
wshã£ã¦ãä½ããããã¨ãããã³ã«ããããªActiveXãªãã¸ã§ã¯ããå¼ã³åºããªãããããªãã£ããã§ãããã©ãã
æ¯åãªãã¡ã¬ã³ã¹ãæ¢ãã®ã大å¤ãªã®ã§ãã¤ãããããªããããã¾ã¨ãã¦ããã³ãã¬ã¼ãã«ãã¾ããã
ããããã¼ã¹ã«wshã¹ã¯ãªãããæ¸ãã°ããã¤ãããã¯æ¥½ãã§ããã¯ãã§ãã
ããããããã§æ¸ãã¦ãæãå¤ãã®ã§ãããã³ãã大æè¿ã§ãã
注æç¹
- windowsXP SP2 Windows Script Host Version 5.6ã§åä½ç¢ºèªãã¦ãã¾ãã
- XMLã¯ãWeb.getXML()ãhtmlã¯ãWeb.getText()ãWeb.getDom()ããã¤ããªã¯ãweb.getResponseBody()ã使ã£ã¦ä¸ããã
- Web.getXML()ã§htmlãã¡ã¤ã«ãåå¾ãããã¨ãã¦ãä½ãåãã¾ããã
- Web.getText()ãWeb.getDom()ã§ãxmlãã¡ã¤ã«ãåå¾ãããã¨ããã¨ãæåã³ã¼ãå¤æãä¸æããããæååããã¾ãã
使ãæ¹
ã½ã¼ã¹ã®464è¡ç®ã«ããã³ã¡ã³ã以éã«ã½ã¼ã¹ãæ¸ãã¦ãã ããã
//----------------------------------------------------------------------------- // ãã®ã¸ãã«ã½ã¼ã¹ãæ¸ã //-----------------------------------------------------------------------------
ä»æ§ä¸è¦§
é£æ³é å
é åå | è¦ç´ å | 説æ |
---|---|---|
File | writeResponseBody( responseBody, path ) | pathã«responseBodyãæ¸ãè¾¼ãã webããåå¾ãããã¤ããªãã¼ã¿ããã¡ã¤ã«ã«æ¸ãè¾¼ãéã«ä½¿ç¨ |
File | read( path ) | ãã¡ã¤ã«ããããã¹ããã¼ã¿ãåå¾ |
File | write( path, str, overwrite ) | ããã¹ããã¡ã¤ã«ã«æ¸ãè¾¼ã¿( overwrite:true ã§ä¸æ¸ã ) |
File | append( path, str ) | ããã¹ããã¡ã¤ã«ã«è¿½è¨( åå¨ããªãå ´åãæ°è¦ä½æ ) |
File | pwd() | ã«ã¬ã³ããã£ã¬ã¯ããªåå¾ |
File | getFiles( path ) | ãã¡ã¤ã«ä¸è¦§ãé åã§åå¾ |
File | getDirs( path ) | ãµããã£ã¬ã¯ããªä¸è¦§ãé åã§åå¾ |
File | isFile( path ) | ãã¡ã¤ã«ã®åå¨ç¢ºèª |
File | isDir( path ) | ãã£ã¬ã¯ããªã®åå¨ç¢ºèª |
File | mkdir( path ) | ãã£ã¬ã¯ããªä½æ |
File | delFile( path ) | ãã¡ã¤ã«åé¤ |
File | delDir( path ) | ãã£ã¬ã¯ããªåé¤ |
Web | getResponseBody( url, args ) | webããResponseBodyãåå¾ã URLã«æ¸¡ãå¼æ°ã¯argsã«é£æ³é åã§å ¥ãã¦ãOK ResponseBodyã¯File.writeResponseBody()ã§ããã¡ã¤ã«ã«æ¸ãè¾¼ãã |
Web | getText( url, args ) | webããããã¹ããã¼ã¿ãåå¾ã URLã«æ¸¡ãå¼æ°ã¯argsã«é£æ³é åã§å ¥ãã¦ãOK |
Web | getXML( url, args ) | webããXMLãã¼ã¿ãåå¾ã URLã«æ¸¡ãå¼æ°ã¯argsã«é£æ³é åã§å ¥ãã¦ãOK |
Web | getDom( url, args ) | webããããã¹ããåå¾ãã¦ãDOMãªãã¸ã§ã¯ãã«å¤æã URLã«æ¸¡ãå¼æ°ã¯argsã«é£æ³é åã§å ¥ãã¦ãOK |
Web | postResponseBody( url, args ) | ãã¼ã¿ãpostãã¦ãResponseBodyãåå¾ã postããæ å ±ã¯ãargsã«é£æ³é åã§å ¥ãã ResponseBodyã¯File.writeResponseBody()ã§ããã¡ã¤ã«ã«æ¸ãè¾¼ãã |
Web | postText( url, args ) | ãã¼ã¿ãpostãã¦ãããã¹ããã¼ã¿ãåå¾ã postããæ å ±ã¯ãargsã«é£æ³é åã§å ¥ãã |
Web | postXML( url, args ) | ãã¼ã¿ãpostãã¦ãXMLãã¼ã¿ãåå¾ã postããæ å ±ã¯ãargsã«é£æ³é åã§å ¥ãã |
Web | postDom( url, args ) | ãã¼ã¿ãpostãã¦ãåå¾ããããã¹ããDOMãªãã¸ã§ã¯ãã«å¤æã postããæ å ±ã¯ãargsã«é£æ³é åã§å ¥ãã |
Arg | unNamed | é åè¦ç´ ãååãªãå¼æ°ãæ ¼ç´ |
Arg | getNamed(name) | ååä»ãå¼æ°ãåå¾ |
Arg | isNamed(name) | ååä»ãå¼æ°ã®åå¨ç¢ºèª |
é¢æ°
é¢æ°å | 説æ |
---|---|
sleep(ms) | ã¹ãªã¼ã(ms) |
print(str) | æååãã³ãã³ãã©ã¤ã³ã«åºå |
dump(obj) | 対象ã®ãªãã¸ã§ã¯ããfor in ãã¦ä¸èº«ãã³ãã³ãã©ã¤ã³åºå |
domDump(obj) | 対象ã®DOMãªãã¸ã§ã¯ãã®ä¸èº«ãã³ãã³ãã©ã¤ã³åºå |
readLine() | ã³ãã³ãã©ã¤ã³ãå ¥åå¾ ã¡ã«ãããæ»ãå¤ã§å ¥åå¤ãåå¾ |
confirm(str) | ã³ãã³ãã©ã¤ã³ã§ï¼»Y/Nï¼½ã®å
¥åå¾
ã¡ã«ãããå¼æ°ã¯å
¥åå¾
ã¡æã«è¡¨ç¤ºããããã¹ãã æ»ãå¤ã¯trueï¼Yãfalseï¼N |
UnitTest
http://kasei-san.sakura.ne.jp/wsh/lib/UnitTest.js
æ®ã©ã®ã¡ã½ããã使ã£ã¦ããã®ã§ããµã³ãã«ã³ã¼ã代ããã«ãªãã¨æãã¾ãã
åä½æé
- UnitTest.jsãwshScriptTemp.jsã¨åããã£ã¬ã¯ããªã«ããã£ã¬ã¯ããªãlibããä½æãã¦æ ¼ç´ã
- wshScriptTemp.jsã®464è¡ç®ã®ã³ã¡ã³ãã¢ã¦ããå¤ãã
- wshScriptTemp.jsãå®è¡
//----------------------------------------------------------------------------- // ãã®ã¸ãã«ã½ã¼ã¹ãæ¸ã //----------------------------------------------------------------------------- //UnitTest(); // â ã³ã¡ã³ãã¢ã¦ãåé¤ã§UnitTestéå§
ãã®ä»
ã©ã¤ãã©ãªåå¾æ©è½
wshScriptTemp.jsã¨åããã£ã¬ã¯ããªã«ããã£ã¬ã¯ããªãlibããããã¨ããã®ä¸ã®jsãã¡ã¤ã«ãå
¨ã¦evalãã¾ãã
ç¾å¨ä½æããã©ã¤ãã©ãªä¸è¦§
http://kasei-san.sakura.ne.jp/wsh/lib/Tumblr.js â Tumblrで色々遊ぶためのwshスクリプト作った
TODO(æ°ãåããé ã«å®è£ )
- $ã¨ãDOMç³»ã®æ©è½è¿½å
- multipart/form-dataã§ãã¤ããªãã¼ã¿ã®POST
- (å¿ è¦ã«ãªã£ãã)æåã³ã¼ãã®å¤æå¦çã追å
- å°ãéãã§ããªãã¦ãããCodeReposã«ä¸ããã
Tumblrã®APIã§éã¶ã©ã¤ãã©ãªãä½ã- ãã¡ã¤ã«ããã£ã¬ã¯ããªã®ã³ãã¼
- wscriptããã®å®è¡ã«ã対å¿
å¤æ´å±¥æ´
2008/02/15
- File.write() 追å
- File.append() 追å
- Web.getDom() 追å
- domDump() 追å
- readLine() 追å
- confirm() 追å
- ã©ã¤ãã©ãªåå¾æ©è½è¿½å
- UnitTest.js 追å
2008/02/16
- Web.get***ã®å¼æ°ãæ£ãã渡ããã¦ããªãã£ãã®ãä¿®æ£ã
2008/05/03
- TumblrAPIã§éã¶ããã®libã追å ã
çµç·¯
wshã¹ã¯ãªããã§ä½ããããã¨ãã«ä¸ã
調ã¹ãã®ãé¢åãªã®ã§ä½æã
wshã¹ã¯ãªããä½æã®æ·å±
ãä¸ããããè¯ããªã¨ã
åèãªã³ã¯
åèã«ããã¦ããã ãã¾ãããæè¬ï¼
JScript シェル - へたっぴ日記
[WSH入門]バッチファイルからWSHへ インデックス
ãããªæãã