人力検索はてな
モバイル版を表示しています。PC版はこちら
i-mobile

UWSCでの質問です。

ソースファイルの中に「←現在"0"と表示されている取引損益のデーターを取得したい。」の様に質問を2箇所書き入れてあります。
そのデーターを取得するコードを教えて下さい。

なお、ソースファイルが長いのでコメント欄に書きます。

●質問者: iwana1999
●カテゴリ:ウェブ制作
○ 状態 :終了
└ 回答数 : 1/1件

▽最新の回答へ

1 ● lang_and_engine
●1000ポイント ベストアンサー

こんにちは。
例のごとく,下記のコードで実際に動作しますので,動かしてみてください。



// 対象Webページの構造の要点:
// ・tableが4つある。上から順に,基準通貨,トランザクション,ポジション,期初期末情報。
// ・1つ目から3つ目までのtable内には,入れ子のtable要素は存在しない。
// ・4つ目の期初期末情報のtableは,横に3セルあって,左端と右端のセル内には入れ子でtableがある。
// ・その入れ子になった2つのtableのそれぞれの中から,情報を取得したい。


// アクセスしたいページのURL
url = "http://name-of-this-site.org/coding/dummy/1388102098q/"

// このURLの中で,操作したいHTMLソースとは別に,
// サーバが勝手に広告とかを表示するのでtableタグの個数が変わってしまう場合がある。
// その場合のために,サーバが勝手に表示する広告のtableをスキップして考えるために,オフセットを設ける。
// アクセスするページの状況によって,適宜この値を書き変えること。
table_count_offset = 0


// 新規IEオブジェクトを作成
ie = createOLEobj("InternetExplorer.Application")

// 起動中のIEを見えるように
ie.visible = True
wid = hndtoid( ie.hwnd )
acw( wid )


// 対象ページを開く
ie.navigate( url )
ie_wait( ie )



// まず,期初期末情報のテーブルを取得
tables = ie.document.getElementsByTagName("table")
ireko_table_left = tables.item( table_count_offset + 4 ) // 5つ目
//msgbox( ireko_table_left.innerHTML )

// 42列目の取引損益情報を抽出
target_tr = ireko_table_left.getElementsByTagName("tr").item( 3 )
//msgbox( target_tr.innerHTML )
target_td = target_tr.getElementsByTagName("td").item( 1 )
soneki = target_td.innerText

msgbox( "取引損益は" + soneki )


// 右側の入れ子tableを取得
ireko_table_right = tables.item( table_count_offset + 5 ) // 6つ目

// 22列目の期末預金情報を抽出
target_tr = ireko_table_right.getElementsByTagName("tr").item( 1 )
target_td = target_tr.getElementsByTagName("td").item( 1 )
kimatsy_yokin = target_td.innerText

msgbox( "期末預金は" + kimatsy_yokin )





// IEがビジー状態の間待ちます
procedure ie_wait( ie )
 repeat
 sleep( 0.1 )
 until ( ! ie.busy ) and ( ie.readystate = 4 )
 sleep( 0.1 )
fend


// コード全体の参考:
// http://d.hatena.ne.jp/language_and_engineering/20090729/p1
// および http://q.hatena.ne.jp/1387280635


lang_and_engineさんのコメント
もし問題がないようでしたら,一定期間が経過した後でテスト用のURLは閉鎖します。 その際には,このコメントも削除します。 ご了承ください。 動作報告をお待ちしております。

iwana1999さんのコメント
lang_and_engineさま いつも初心者に分かりやすい回答を頂きまして有り難うございます。 テスト用URLでは期待通りに稼動しましたので、目的のページで確認します。

iwana1999さんのコメント
実は、お願いしていたページは業者が作ったEXEファイルを開く形式になっておりまして、インターネットブラウザを使用しておりません。 従って、ダミーのURLをどのように変えて良いのかわからない状態なのですがデーターを取得したいページに入るにはIDとパスワードが必要でのですので公開する事が出来ません。 そこで、メールで必要情報をお送りしたいのですが、ご教示頂けますでしょうか? 恐れ入りますが、宜しくお願い致します。

iwana1999さんのコメント
お忙し中、ご丁寧に指摘及び度指導を頂きまして有り難うございます。 餅は餅屋と言いますがプロの方とは考え方が月とスッポンほど違うなあと改めて感じ入っている次第です。 一通り読ませて頂きました上でのお願いです。 1.別質問のデーター取得の件は、質問が締めきりになりましたらポイント送信という形で継続してお願いさせて頂きたいと思いますので、宜しくお願い致します。 2.今回のソースがブラウザ経由でない事は分かっていたのですが、余り重要に考えておりませんでした。 次回から,前提条件として書きますので宜しくお願い致します。 3.確かにリアル取引画面に入ることは、受けて頂く方も負担になると思いますのでデモ口座を開きます。 当該ページはリアルとデモ口座は同じシステムを切り替えて使って降りますのでデモ口座でも同じ内容と思います。 参考にデモ口座のソースファイルを貼り付けます。 それではお手数をお掛け致しますが宜しくお願い致します。 ---------------------------------------------------- nowrap>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td nowrap>期間:</td><td nowrap>日次</td></tr> <tr><td nowrap>顧客氏名:</td><td nowrap>Test System</td><td nowrap>&nbsp;</td><td nowrap>開始日時:</td><td nowrap>12/26/2013 00:00:00</td></tr> <tr><td rowspan=2 valign=top>顧客住所:<td rowspan=2 valign=top> , </td><td nowrap>&nbsp;</td><td nowrap>終了日時:</td><td nowrap>12/27/2013 00:54:59</td></tr> <tr><td nowrap></td><td nowrap>Trader's Login:</td><td nowrap>demo7694</td></tr> <tr><td nowrap>基準通貨:</td><td nowrap>? (JPY: Japanese Yen)</td><td nowrap></td><td nowrap></td><td nowrap></td></tr> </table><br><center>取引明細 (詳細)</center><table class="rep_table" border=1 cellspacing=0 width="100%"><tr><th>クローズ日時 </th><th>種別 </th><th>Trade ID</th><th>Trade Size</th><th>番号</th><th>通貨ペア </th><th>ロット </th><th>売買 </th><th>オープン日時 </th><th>建値</th><th>Open<br>Notional<br>value</th><th>仕切値 </th><th>Close<br>Notional<br>value</th><th>入出金額 </th><th>G?損益</th><th>手数料</th><th>金利</th><th>N?損益</th><th colspan=2>OM<br>Pts/?</th><th colspan=2>CM<br>Pts/?</th><th>預金</th><th>残高</th><th>使用証拠金</th><th>User</th><th>備考</th><tr align=right><td align=center nowrap>12/27/13,<br>00:36:56<td align=center nowrap>DP<td align=center nowrap><td align=center nowrap><td align=center nowrap><td align=center nowrap><td nowrap><td align=center nowrap><td align=center nowrap><td nowrap><td nowrap><td nowrap><td nowrap><td nowrap><b>200,000</b><td nowrap><td nowrap><td nowrap><td nowrap><td nowrap><td nowrap><td nowrap><td nowrap><td nowrap>200,000<td nowrap>200,000<td nowrap>0<td align=left nowrap>System<td align=left nowrap>REGISTRATION</tr> <tr align=right><th align=left colspan=14>取引損益計</td><th nowrap>0<th nowrap><i><font color=green>0</font></i><th nowrap><i><font color=green>0</font></i><th nowrap>0<th nowrap><i><font color=green>0</font></i><th nowrap><i><font color=green>0</font></i><th nowrap>0<th nowrap>0<th align=left colspan=5></td></tr> <tr align=right><th align=left colspan=14>期間中損益総計</td><th nowrap>0<th nowrap>0<th nowrap>0<th nowrap>0<th nowrap>0<th nowrap>0<th nowrap>0<th nowrap>0<th align=left colspan=5></td></tr> </table><br><br><center>現在保有のポジション</center><table class="rep_table" border=1 cellspacing=0 width="100%"><tr><th rowspan=2>Trade ID</th><th rowspan=2>番号</th><th rowspan=2>Instr. Type</th><th rowspan=2>通貨ペア </th><th rowspan=2>ロット </th><th rowspan=2>売買 </th><th rowspan=2>建値</th><th rowspan=2>Open<br>Notional<br>value</th><th rowspan=2>オープン日時 </th><th colspan=2>OM</th><th rowspan=2>仕切値 </th><th rowspan=2>Close<br>Notional<br>value</th><th rowspan=2>G?損益</th><th rowspan=2>手数料</th><th rowspan=2>金利</th><th rowspan=2>N?損益</th><th rowspan=2>User</th><th rowspan=2>備考</th></tr><tr><th>Pts</th><th>?</th></tr><tr align=right><th align=left colspan=4>Global totals</td><th nowrap>0<th align=left colspan=2></td><th nowrap>0<th align=left colspan=1></td><th nowrap>0<th nowrap>0<th align=left colspan=1></td><th nowrap>0<th nowrap>0<th nowrap>0<th nowrap>0<th nowrap>0<th align=left colspan=2></td></tr> </table><table border=0 width=100%><tr><td valign=top width=40%><table border=0 cellpadding=0 cellspacing=1><tr><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr><tr><td nowrap>期初預金:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>期初残高:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>取引損益:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>手数料:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>金利:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>入金:</td><td nowrap align=right>200,000</td></tr> <tr><td nowrap>出金:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>アジャストメント:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>Net D/W/A:</td><td nowrap align=right>200,000</td></tr> </table></td><td width=20%>&nbsp;</td><td valign=top width=40%><table border=0 cellpadding=0 cellspacing=1><tr><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr><tr><td nowrap>期末預金:</td><td nowrap align=right>200,000</td></tr> <tr><td nowrap>含み損益:</td><td nowrap align=right>0</td></tr> <tr><td nowrap><table border=1 width="100%" cellpadding=0 cellspacing=0><tr><td nowrap><b>期末残高:</b></td></tr> </table></td><td><table border=1 width="100%" cellpadding=0 cellspacing=0><tr><td nowrap align=right><b>200,000</b></td></tr> </table></td></tr> <tr><td nowrap>使用証拠金:</td><td nowrap align=right>0</td></tr> <tr><td nowrap>余剰証拠金:</td><td nowrap align=right>200,000</td></tr> <tr><td nowrap>MC Deposit Required:</td><td nowrap align=right>0</td></tr>

質問者から

業者のURLです。
http://infinity-space.com/ja/demonstration.html

下の方にデモシステムのダウンロードリンクがありますのでお手数ですがシステムをダウンロードして頂きまして、システムを起動するときに、username=demo7694,p/w=4800、accoutType=demoと入力して頂ければ立ち上がります。

次に、データーを取得するページの設定ですが、HPを開いて上から2段目の行に、Main,Cahrts,Detailedinfo,Position,History,Reports,と文字が並んでいますので、Reportsを選択してRun Reportを押しますと、資金の取得ページが現れます。

以上、宜しくお願い致します。(用済み後に削除します)


関連質問

●質問をもっと探す●



0.人力検索はてなトップ
8.このページを友達に紹介
9.このページの先頭へ
対応機種一覧
お問い合わせ
ヘルプ/お知らせ
ログイン
無料ユーザー登録
はてなトップ