WinHTTPRequest

Z

z.yxwv

I am using WinHTTPRequest Services in MS Access on my client computer
[not server].

All seems to be OK except that the file returned is not text.

Thoughts?

##############################################################
This subroutine in VBA Module:

Option Compare Database

Dim WinHttpReq As WinHttp.WinHTTPRequest

Public Sub subGetWebPage()

' Create an instance of the WinHTTPRequest ActiveX object.
Set WinHttpReq = New WinHTTPRequest

' Create an array to hold the response data.
Dim intFileReturned As String

' Assemble an HTTP Request.
WinHttpReq.Open "GET", "http://www.google.com.au", False

' Send the HTTP Request.
WinHttpReq.Send

' Put status and content type into status text box.
Debug.Print WinHttpReq.Status & " - " & WinHttpReq.StatusText

intFileReturned = WinHttpReq.ResponseBody

' Put response data into a file.
Debug.Print "File Returned: " & intFileReturned

End Sub

#######################################################
immediate screen shows:

200 - OK
File Returned: ?????????????????????
•????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
(?????????????????????????????????????????????????????????????????????????????????????????
8?????????????(????(??????????????????????
8?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
=???????????????????????????????????????????????????????????????????????????????
Z?????????????????????????????????
=???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
‰?????
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
•???????????????????????????????????????????????
•?????????????????????????????????????????????
•??????????????????????????????????????????????
•???????????????????????????????????
•?????????????????????????????????????????????????
6?????????????????????????????????????????????????????????????????????????????????
•?????????????????????????????????????????????????
•?????????????????????????????????????????????????
•??????????????????????????????
6??????????????????????????????????????????????????????????????????????????????????????
•????????????????????????????????????????
•????????????????????????????????????????????
•????????????????????????????????????????????????????????????????????????????
•???????????????????
6???????????????????????????????????????????????????????????????????????????????????????????????????
6?????4???????????????????‰
‰??????????????????????????????????????????-
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
=?????‰????????????????
•????????????????????????????????????????????????????????????????????????????
4?????????????????4??????????????????????4??????????????`??????????
•?????????4??????????
4???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
4?????????????????????????????????????????
4????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????
4?????????????????????????????????????????????????
 
L

Lou

I am using WinHTTPRequest Services in MS Access on my client computer
[not server].

All seems to be OK except that the file returned is not text.

Thoughts?

##############################################################
This subroutine in VBA Module:

Option Compare Database

Dim WinHttpReq As WinHttp.WinHTTPRequest

Public Sub subGetWebPage()

    ' Create an instance of the WinHTTPRequest ActiveX object.
    Set WinHttpReq = New WinHTTPRequest

    ' Create an array to hold the response data.
    Dim intFileReturned As String

    ' Assemble an HTTP Request.
    WinHttpReq.Open "GET", "http://www.google.com.au", False

    ' Send the HTTP Request.
    WinHttpReq.Send

    ' Put status and content type into status text box.
    Debug.Print WinHttpReq.Status & " - " & WinHttpReq.StatusText

    intFileReturned = WinHttpReq.ResponseBody

    ' Put response data into a file.
    Debug.Print "File Returned: " & intFileReturned

End Sub

#######################################################
immediate screen shows:

200 - OK
File Returned: ?????????????????????
•??????????????????????????????????????????????????????????????????????????­??????????????????????????????????????????????????????????????
(??????????????????????????????????????????????????????????????????????????­???????????????
8?????????????(????(??????????????????????
8??????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????????????­??????????????????????????????????????????????????????????????
=??????????????????????????????????????????????????????????????????????????­?????
Z?????????????????????????????????
=??????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????????????­???????????
‰?????
???????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????
•???????????????????????????????????????????????
•?????????????????????????????????????????????
•??????????????????????????????????????????????
•???????????????????????????????????
•?????????????????????????????????????????????????
6??????????????????????????????????????????????????????????????????????????­???????
•?????????????????????????????????????????????????
•?????????????????????????????????????????????????
•??????????????????????????????
6??????????????????????????????????????????????????????????????????????????­????????????
•????????????????????????????????????????
•????????????????????????????????????????????
•??????????????????????????????????????????????????????????????????????????­??
•???????????????????
6??????????????????????????????????????????????????????????????????????????­?????????????????????????
6?????4???????????????????‰
‰??????????????????????????????????????????-
???????????????????????????????????????????????????????????????????????????­????????????????????????????????????????????
=?????‰????????????????
•??????????????????????????????????????????????????????????????????????????­??
4?????????????????4??????????????????????4??????????????`??????????
•?????????4??????????
4??????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????????????­??????????????????????????????????????????????????????
4?????????????????????????????????????????
4??????????????????????????????????????????????????????????????????????????­???????????????????????????????????????????????????????????????????????????­???????????????????????????????????????
4?????????????????????????????????????????????????


I'll assume you want the text of the web page--that which you see when
choose the menu option "View Source"

To receive the text substitute:

intFileReturned = WinHttpReq.ResponseText
for
intFileReturned = WinHttpReq.ResponseBody

It will return the string starting "<html><meta>"...
 
Z

z.yxwv

I am using WinHTTPRequest Services in MS Access on my client computer
[not server].
All seems to be OK except that the file returned is not text.

##############################################################
This subroutine in VBA Module:
Option Compare Database
Dim WinHttpReq As WinHttp.WinHTTPRequest
Public Sub subGetWebPage()
    ' Create an instance of the WinHTTPRequest ActiveX object.
    Set WinHttpReq = New WinHTTPRequest
    ' Create an array to hold the response data.
    Dim intFileReturned As String
    ' Assemble an HTTP Request.
    WinHttpReq.Open "GET", "http://www.google.com.au", False
    ' Send the HTTP Request.
    WinHttpReq.Send
    ' Put status and content type into status text box.
    Debug.Print WinHttpReq.Status & " - " & WinHttpReq.StatusText
    intFileReturned = WinHttpReq.ResponseBody
    ' Put response data into a file.
    Debug.Print "File Returned: " & intFileReturned
#######################################################
immediate screen shows:
200 - OK
File Returned: ?????????????????????
•??????????????????????????????????????????????????????????????????????????­­??????????????????????????????????????????????????????????????
(??????????????????????????????????????????????????????????????????????????­­???????????????
8?????????????(????(??????????????????????
8??????????????????????????????????????????????????????????????????????????­­??????????????????????????????????????????????????????????????????????????­?­?????????????????????????????????????????????????????????????????????????­??­????????????????????????????????????????????????????????????????????????­???­??????????????????????????????????????????????????????????????
=??????????????????????????????????????????????????????????????????????????­­?????
Z?????????????????????????????????
=??????????????????????????????????????????????????????????????????????????­­??????????????????????????????????????????????????????????????????????????­?­?????????????????????????????????????????????????????????????????????????­??­???????????
‰?????
???????????????????????????????????????????????????????????????????????????­­???????????????????????????????????????????????????????????????????
•???????????????????????????????????????????????
•?????????????????????????????????????????????
•??????????????????????????????????????????????
•???????????????????????????????????
•?????????????????????????????????????????????????
6??????????????????????????????????????????????????????????????????????????­­???????
•?????????????????????????????????????????????????
•?????????????????????????????????????????????????
•??????????????????????????????
6??????????????????????????????????????????????????????????????????????????­­????????????
•????????????????????????????????????????
•????????????????????????????????????????????
•??????????????????????????????????????????????????????????????????????????­­??
•???????????????????
6??????????????????????????????????????????????????????????????????????????­­?????????????????????????
6?????4???????????????????‰
‰??????????????????????????????????????????-
???????????????????????????????????????????????????????????????????????????­­????????????????????????????????????????????
=?????‰????????????????
•??????????????????????????????????????????????????????????????????????????­­??
4?????????????????4??????????????????????4??????????????`??????????
•?????????4??????????
4??????????????????????????????????????????????????????????????????????????­­??????????????????????????????????????????????????????????????????????????­?­??????????????????????????????????????????????????????
4?????????????????????????????????????????
4??????????????????????????????????????????????????????????????????????????­­??????????????????????????????????????????????????????????????????????????­?­???????????????????????????????????????
4?????????????????????????????????????????????????

I'll assume you want the text of the web page--that which you see when
choose the menu option "View Source"

To receive the text substitute:

    intFileReturned = WinHttpReq.ResponseText
for
    intFileReturned = WinHttpReq.ResponseBody

It will return the string starting "<html><meta>"...- Hide quoted text -

- Show quoted text -

Thanks for that
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top