//--ユーザー定義 id="***" pass="***" csv_file_dir=GET_CUR_DIR //CSV保存先のディレクトリ指定(例はカレントディレクトリ) //csv_file_dir="" //CSV作成しない場合は空欄で //--初期設定 HASHTBL list HASHTBL content Public OkBtn dim total_k,total_l,total_c,yy,mm IE = CreateOLEObj("InternetExplorer.Application") IE.Visible = true dt=Gettime() y=G_TIME_YY4 m=G_TIME_MM //--集計月取得 IE.Navigate("about:blank") BusyWait(IE) doc=IE.document yy="" yy=yy+"" for i=1 to 12 ifb i=m mm=mm+"" else mm=mm+"" endif next HTML=HTML_s HTML=Chgmoj(HTML,"$_y_$",yy) HTML=Chgmoj(HTML,"$_m_$",mm) doc.write(HTML) OleEvent(doc.body.all["OkBtn"], "HTMLInputTextElementEvents2", "OnClick", "clk_OkBtn") Repeat Sleep(0.1) Until OkBtn=1 mon=IEgetdata(IE,"mon") year=IEgetdata(IE,"year") mon=VAL(mon) year=VAL(year) ifb !(csv_file_dir="") if copy(csv_file_dir,length(csv_file_dir))="\" then csv_file_dir=copy(csv_file_dir,1,length(csv_file_dir)-1) csv_file=csv_file_dir+"\"+year+"年"+mon+"月度ポイント獲得集計.csv" endif //--データ集計 IE.Navigate("https://www.rakuten.co.jp/myrakuten/login.html") sleep(1) BusyWait(IE) for i=0 to doc.all.tags("input").length-1 ifb pos(" 次へ ",doc.all.tags("input").item(i).value)>0 doc.all.tags("input").u.value=ID doc.all.tags("input").p.value=PASS clickIE(IE," 次へ ",1) sleep(1) IE.Navigate("https://point.rakuten.co.jp/history/") BusyWait(IE) break endif next next_page=1 While next_page>0 table=doc.getElementsByTagName("table") for i=0 to table.length-1 ifb table.item(i).rows(1).cells(0).innerText="利用日<#cr>獲得日" o_table=table.item(i) break endif next for i=3 to o_table.rows.length-1 o_row=o_table.rows(i) t_mon=val(Betweenstr(o_row.cells(0).innerText,"<#CR>","/")) //Msgbox(t_mon) t_year=val(copy(o_row.cells(0).innerText,0,4)) //Msgbox(t_year) ifb t_mon=mon key=o_row.cells(1).innerText //Msgbox(key) if !(list[key,HASH_EXISTS]) then list[key]="" for ii=2 to 5 text=o_row.cells(ii).innerText text=Chgmoj(text,"["+Betweenstr(text,"[","]")+"]","") text=Chgmoj(text,"(全て)","") list[key]=list[key]+text+"|" next list[key]=list[key]+"@" endif ifb t_year+copy("0"+t_mon,length("0"+t_mon)-2)0 if !(clickIE(IE,"次の30件 >",0)) then next_page=0 endif wend //--データテーブル作成 table_s="";table_e="
" td="";etd="";tr="";etr="" htm=table_s+"#66FFCC<#DBL>>"+td+"サービス"+etd+""+"内容"+etd+td+"獲得ポイント"+etd+td+"利用ポイント"+etd+td+"データー数"+etd+etr for n = 0 to Length(list)-1 sum_k=0;sum_l=0;sum_c=0;num=0 str=list[n, HASH_VAL] Repeat item=Token("@",str) key=Token("|",item) if !(content[key,HASH_EXISTS]) then content[key]="" content[key]=content[key]+item+"@" Until str="" for nn = 0 to Length(content)-1 str2=content[nn, HASH_VAL] k_point=0;l_point=0;c_point=0 Repeat data=Token("@",str2) func=Token("|",data) p=Token("|",data) p=val(Chgmoj(p,"つぶやく","")) ifb p>0 k_point=k_point+p elseif p<0 l_point=l_point+p endif c_point=c_point+1 Until str2="" sum_k=sum_k+k_point sum_l=sum_l+l_point sum_c=sum_c+c_point num=num+1 ifb num=1 and nn=Length(content)-1 htm=htm+"#FFFFCC<#DBL>>" else htm=htm+tr endif htm=htm+td+list[n, HASH_KEY]+etd htm=htm+td+content[nn, HASH_KEY]+etd htm=htm+td+k_point+etd+td+l_point+etd+td+c_point+etd+etr next ifb num>1 htm=htm+"#FFFFCC<#DBL>>"+td+list[n, HASH_KEY]+etd htm=htm+td+"合計"+etd htm=htm+td+sum_k+etd+td+sum_l+etd+td+sum_c+etd+etr endif content=HASH_REMOVEALL total_k=total_k+sum_k total_l=total_l+sum_l total_c=total_c+sum_c next htm=htm+"#FFCCFF<#DBL>>"+td+"総計"+etd htm=htm+td+" "+etd htm=htm+td+total_k+etd+td+total_l+etd+td+total_c+etd+etr htm=htm+table_e htm=head+"

"+mon+"月度集計結果

"+htm+"" IE.Navigate("about:blank") BusyWait(IE) doc=IE.document doc.write(htm) ifb !(csv_file="") table_to_csv(doc.getElementsByTagName("table").item(0),csv_file) endif //------ Procedure BusyWait(ie) Sleep(0.5) // Wait Const TIME_OUT = 90 tm = Gettime() repeat Sleep(0.2) ifb Gettime() - tm > TIME_OUT MsgBox("Time Out:BusyWait") ExitExit endif until (! ie.busy) and (ie.readyState=4) Sleep(0.5) Fend //------ Function clickIE(IE,c_str,c_type) Result=false doc=IE.document Select c_type case 0 //link for i=0 to doc.links.length-1 ifb pos(c_str,doc.links(i).innerText)>0 doc.links(i).click() Result=true Break endif next BusyWait(IE) case 1 //btn for i=0 to doc.all.tags("input").length-1 ifb pos(c_str,doc.all.tags("input").item(i).value)>0 doc.all.tags("input").item(i).click() Result=true Break endif next BusyWait(IE) Selend Fend TextBlock HTML_s
集計年度を選択してください
集計月を選択してください
EndTextBlock TextBlock head EndTextBlock //-- Procedure clk_OkBtn()  OkBtn=1 Fend //-- Procedure table_to_csv(table,file) fid=Fopen(file,F_READ or F_WRITE) for i=0 to table.rows.length-1 for ii=0 to table.rows(i).cells.length-1 Fput(fid,table.rows(i).cells(ii).innerText,i+1,ii+1) next next Fclose(fid) fend