2/16 ネットワークプログラミング Part2
昨日の続きです。一応、直接サーバーからホームページの取得するプログラムができたので公開します。WinInet API,VBです。Dim lngInetHandle As Long Dim lngUrlHandle As Long Dim intRet As LongDim bytArray() As ByteDim strUrl As StringDim txtRecvData As StringstrUrl = "www.sbc-fujisawa.com"lngInetHandle = InternetOpen(scUserAgent, _INTERNET_OPEN_TYPE_PRECONFIG, _vbNullString, _vbNullString, _lngUrlHandle = InternetOpenUrl(lngInetHandle, _strUrl, _vbNullString, _0, _INTERNET_FLAG_RELOAD, _0)intRet = InternetReadFile(lngUrlHandle, _bytArray(lngTotalRead), _WI_READ_READSIZE, _lngReadSize)InternetCloseHandle (lngUrlHandle)InternetCloseHandle (lngInetHandle)txtRecvData= StrConv(bytArray, vbUnicode)Debug.Print txtRecvDateWinInet APIの宣言文はDeclare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _(ByVal sAgent As String, _ByVal lAccessType As Long, _ByVal sProxyName As String, _ByVal sProxyBypass As String, _ByVal lFlags As Long) As LongDeclare Function InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" _(ByVal hInternetSession As Long, _ByVal sUrl As String, _ByVal sHeaders As String, _ByVal lHeadersLength As Long, _ByVal lFlags As Long, _ByVal lContext As Long) As LongDeclare Function InternetReadFile Lib "wininet.dll" _(ByVal hFile As Long, _ByRef lpBuffer As Any, _ByVal lNumBytesToRead As Long, _ByRef lNumberOfBytesRead As Long) As Integerです。かなり省略して書いていますが大筋はこんな感じです。これで、湘南美容外科のHPを直接サーバーから取得することができました。次は、IDとパスワードが必要なHPの取得ですがInternetConnect,HttpOpenRequest,HttpSendRequestの理解が必要となります。また暗号化されたコードもあるので解読が必要そうです。0000 00 10 db 77 61 10 00 30 1b b8 5e db 08 00 45 00 0010 04 6c 5d 18 40 00 80 06 21 ef c0 a8 03 33 cb d8 0020 e7 d0 06 f0 00 50 db 0a b5 f0 9c d9 e0 53 50 18 0030 ff ff 7b e3 00 00 47 45 54 20 2f 71 3f 73 3d 38 0040 36 39 39 26 64 3d 76 31 26 6b 3d 63 33 26 68 3d 0050 6f 6e 26 7a 3d 6d 20 48 54 54 50 2f 31 2e 31 0d 0060 0a 41 63 63 65 70 74 3a 20 69 6d 61 67 65 2f 67 0070 69 66 2c 20 69 6d 61 67 65 2f 78 2d 78 62 69 74 0080 6d 61 70 2c 20 69 6d 61 67 65 2f 6a 70 65 67 2c 0090 20 69 6d 61 67 65 2f 70 6a 70 65 67 2c 20 61 70 00a0 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 73 68 6f 63 00b0 6b 77 61 76 65 2d 66 6c 61 73 68 2c 20 61 70 70 00c0 6c 69 63 61 74 69 6f 6e 2f 76 6e 64 2e 6d 73 2d 00d0 65 78 63 65 6c 2c 20 61 70 70 6c 69 63 61 74 69 00e0 6f 6e 2f 76 6e 64 2e 6d 73 2d 70 6f 77 65 72 70 00f0 6f 69 6e 74 2c 20 61 70 70 6c 69 63 61 74 69 6f 0100 6e 2f 6d 73 77 6f 72 64 2c 20 2a 2f 2a 0d 0a 52 ・ ・ ・ぶったおれそうですが、根性で頑張りたいと思います。