Created
March 2, 2014 01:47
-
-
Save yu-tang/9300689 to your computer and use it in GitHub Desktop.
WebScraper for VBA examples
This file contains 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
Option Explicit | |
Sub JRA_Test01() | |
Dim req As WSHttpRequest | |
Dim proc As WSProcessReExecute | |
Dim ret As Collection | |
Dim token As String | |
' 騎手データ > リーディングの HTML から | |
' 「浜中 俊」のリンク先トークンを取得(週ごとに変動する模様) | |
Set req = HttpRequest("", "http://www.jra.go.jp/JRADB/", "accessK.html", "cname=pt01kld0099993101/67", , msoEncodingJapaneseShiftJIS) | |
Set proc = ReExec("tokens", " doAction\('/JRADB/accessK\.html','([\w/]+)'\)"">浜中俊</a>", "cname={1}") | |
token = scrape(req, proc)!tokens(1) | |
'「騎手情報 浜中 俊 (はまなか すぐる)」の HTML から | |
' 「今週の騎乗馬一覧」のトークンを取得 | |
Set ret = scrape(req.SetPostBody(token), proc.SetPattern(" doAction\('/JRADB/accessK\.html','([\w/]+)'\)"">今週の騎乗馬一覧</a>")) | |
token = ret!tokens(1) | |
'「今週の騎乗馬一覧 浜中 俊」の HTML から | |
' 最初の馬情報ページのトークンを取得 | |
Set ret = scrape(req.SetPostBody(token), proc.SetPattern(" doAction\('/JRADB/accessU.html','([\w/]+)'\)")) | |
token = ret!tokens(1) | |
' 馬情報ページを IE で表示 | |
scrape IENavigate(url:="http://www.jra.go.jp/JRADB/accessU.html", PostBody:=token) | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment