下記スレッドの続きです
http://hsp.tv/play/pforum.php?mode=all&num=76926
ニコ生のコメントを取得したいのですが、どうにもうまくいかなくて困っています。
どなたか改良をお願いできませんでしょうか・・・
仕様はこのへん(https://goo.gl/UbcEP7)を参考にしました。
_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#include "hspinet.as"
#include "hspext.as"
#include "hspsock.as"
netinit
sdim NOTEBUF, 65535
screen 0, 640, 480 : gsel 0
PRM_ID = "" ;ニコニコ動画メールアドレス
PRM_PW = "" ;パスワード
PRM_LV = "" ;放送LV番号(LV99999999)
netinit
pos 0, 0
axobj ie1, "Shell.Explorer.2" , 640, 480
ie1 -> "Navigate" "https://secure.nicovideo.jp/secure/"
repeat : wait 1 : if ie1("Busy") = 0 { break } : loop
obj = ie1("Document")
repeat : wait 10 : if( obj("readyState") == "complete" ) { break } : loop
;ログインチェック
obj = ie1("Document") : obj = obj("body") : obj = obj("all", 7)
doc = obj("outerHTML")
ret = instr(doc, 0, "ログイン")
if ret = 35 {
;ログインする
obj = ie1("Document") : obj = obj("forms",0) : obj = obj("input__mailtel")
obj("value") = PRM_ID
obj = ie1("Document") : obj = obj("forms",0) : obj = obj("input__password")
obj("value") = PRM_PW
obj = ie1("Document") : obj = obj("forms",0)
obj->"submit"
repeat : wait 1 : if ie1("Busy") = 0 { break } : loop
}
;放送ステータス取得
ie1 -> "Navigate" strf("http://watch.live.nicovideo.jp/api/getplayerstatus?v=%s", PRM_LV)
repeat : wait 1 : if ie1("Busy") = 0 { break } : loop
obj = ie1("Document") : obj = obj("body")
doc = obj("outerHTML")
idx = instr(doc, 0, "getplayerstatus")
if strmid(doc, idx + 76, 4) = "fail" {
dialog strf("%s は現在放送されていません", PRM_LV)
end
}
gosub *cleanxml_status
notesel doc : notesave "doc.txt"
tag = "title" : gosub *splittag : STS_title = ret
tag = "description" : gosub *splittag : STS_description = ret
tag = "owner_id" : gosub *splittag : STS_owner_id = ret
tag = "owner_name" : gosub *splittag : STS_owner_name = ret
tag = "ticket" : gosub *splittag : STS_ticket = ret
tag = "addr" : gosub *splittag : STS_addr = ret
tag = "port" : gosub *splittag : STS_port = ret
tag = "thread" : gosub *splittag : STS_thread = ret
sockopen 0, STS_addr, int(STS_port)
if stat : dialog "sockopen" + str(stat) : stop
strs = strf("<thread thread=\"%s\" version=\"20061206\" res_from=\"-1\"/>", STS_thread)
sockput strs, 0
if stat : dialog "socket error" : stop
await 0
sockget NOTEBUF,64
if stat : dialog "socket error:" + str(stat) : stop
dialog NOTEBUF
sockclose 0
stop
;ログアウト
ie1 -> "Navigate" "https://account.nicovideo.jp/logout"
repeat : wait 1 : if ie1("Busy") = 0 { break } : loop
end
*splittag
idx1 = instr(doc, 0, strf("<%s>", tag))
if idx1 < 0 : ret = "" : return
idx2 = instr(doc, 0, strf("</%s>", tag))
if idx2 < 0 : idx2 = 99999
ret = strmid(doc, idx1 + strlen(tag) + 2, idx2 - idx1 - strlen(tag) - 2)
return
*cleanxml_status
strrep doc, "</SPAN>", ""
strrep doc, ">", ""
strrep doc, " ", ""
strrep doc, "<", ""
strrep doc, "<DIV class=e>", ""
strrep doc, "<DIV style=\"MARGIN-LEFT: 1em; TEXT-INDENT: -2em\">", ""
strrep doc, "<DIV class=c style=\"MARGIN-LEFT: 1em; TEXT-INDENT: -2em\">", ""
strrep doc, "<DIV>", ""
strrep doc, "</DIV>", ""
strrep doc, "<SPAN class=b> <SPAN class=m><SPAN class=t>", "<"
strrep doc, "<SPAN class=m>", ">"
strrep doc, "/<SPAN class=t>", "</"
strrep doc, "<SPAN class=tx>", ""
strrep doc, "></", "</"
strrep doc, "\n\n", "\n"
strrep doc, "<SPAN class=b>", ""
return