Results 1 to 9 of 9

Thread: Get simply html page from https URL, on XP and 7 ?

  1. #1

    Thread Starter
    Hyperactive Member Couin's Avatar
    Join Date
    Dec 2020
    Posts
    270

    Get simply html page from https URL, on XP and 7 ?

    Hi friends,

    After more than 6 hours to try different codes, unsuccessfully, I come here to ask some help

    I would get some simple datas from a php page. For exemple, a first request to get the last available version of the software:
    https://jinglepalettereloaded.com/page.php?lastver

    And a second to get the changelogs from running version and available update:
    https://jinglepalettereloaded.com/page.php?v=5.1.9

    A form with a Webbrowser control for displayling the changelogs, and the "last available version" data is designed to purpose to the user , to ignore this update (so no longer notificcation until a newer is released).

    The problem is that it runs OK on W10 or W8.1 (probably 8 too), but not in 7 or XP (I know that are olds OS but still useful and used for small apps running on "poor" machines).

    If I understood well, it's related to the Internet Explorer browser, even if there is another default web browser installed. I can not browse the URLs above, from IE in XP and 7.


    Is there a workaround to simply get datas from https url ?

    I saw the Vladimir's (wqweto) VbAsyncSocket library, but Avira rejected compiled exe from Basic / project1 and 2

    Thanks
    Last edited by Couin; Feb 6th, 2023 at 12:16 AM.
    1 Hour vinyl mix live on Eurodance90 each sunday 10:00 PM (French Timezone) - New non-official Jingle Palette update Jingle Palette Reloaded

  2. #2

  3. #3

    Thread Starter
    Hyperactive Member Couin's Avatar
    Join Date
    Dec 2020
    Posts
    270

    Re: Get simply html page from https URL, on XP and 7 ?

    Hi wqweto

    I downloaded the dll, but , sorry, I don't see what to do with it ?

    Thanks
    1 Hour vinyl mix live on Eurodance90 each sunday 10:00 PM (French Timezone) - New non-official Jingle Palette update Jingle Palette Reloaded

  4. #4

    Thread Starter
    Hyperactive Member Couin's Avatar
    Join Date
    Dec 2020
    Posts
    270

    Re: Get simply html page from https URL, on XP and 7 ?

    Hi,

    I Finally near found how to use it.
    I added the dll a reference, removed cls and bas files from project.

    Here is the remaing test code :
    Code:
    Function GetHTTPResponseHTTPS(ByVal Url As String) As String
        On Error GoTo Exit_Routine
        Dim req As New cHttpRequest
        With req
            .SetTimeouts 500, 500, 500, 500
            .Open_ "POST", Url, False
            .SetRequestHeader "Content-Type", "application/json"
            .Option_(WinHttpRequestOption_SslErrorIgnoreFlags) = 13056 '&H3300
            .Send
            If .ResponseText = "" Then
            Else
            WebBrowser1.document.write .ResponseText
            End If
        End With
        Set req = Nothing
      
    Exit Function
    Exit_Routine:
    Exit Function
      
    End Function
    
    Private Sub Command2_Click()
        GetHTTPResponseHTTPS (Text2.Text)
    End Sub
    It runs in IDE, I can compile to exe without having avira blocking, but the script does not run (the webbrowser control remains empty on clicking on Command2, and the app sometimes closes itself after few seconds).
    The dll is in the same folder than the exe. I also tried to copy it in System32 and SysWow64 but it does not change anything.
    1 Hour vinyl mix live on Eurodance90 each sunday 10:00 PM (French Timezone) - New non-official Jingle Palette update Jingle Palette Reloaded

  5. #5
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,094

    Re: Get simply html page from https URL, on XP and 7 ?

    Couple of things: 1. Does this snippet work on Win10? 2. Does this snippet work with the original WinHttpRequest on Win10?

    You can MsgBox Err.Description in Exit_Routine label.

    You can MsgBox .ResponseText after calling Send method.

    cheers,
    </wqw>

  6. #6

    Thread Starter
    Hyperactive Member Couin's Avatar
    Join Date
    Dec 2020
    Posts
    270

    Re: Get simply html page from https URL, on XP and 7 ?

    Hi wqweto

    Thanks for help, I will try to answer as precise as I can

    Quote Originally Posted by wqweto View Post
    1. Does this snippet work on Win10?
    Yes, it works in VB6 IDE on Win10.

    Quote Originally Posted by wqweto View Post
    2. Does this snippet work with the original WinHttpRequest on Win10?
    Just tried, works on Win10 if I remove the underscores after Open and Option parameters.

    Today, I removed the HttpRequest 1.0.3 dll from the reference list (removed in the Windows registry) and re-imported the dll through VB6, and now it work from compiled exe, on Win10.

    Both HttpRequest and WinHttpRequest works in exe, on Win10.

    Quote Originally Posted by wqweto View Post
    You can MsgBox Err.Description in Exit_Routine label.

    You can MsgBox .ResponseText after calling Send method.
    I added and tested on XP/7, and here are the erros I get :

    For WinHttpRequest : A security error occured

    For HttpRequest : Active X component cant't create objet

    Here is my code (for a fraime with 1 textbox, 2 commandbuttons, and 1 webbrowser) :
    Code:
    Function GetHTTPResponseHTTPS(ByVal Url As String) As String
        On Error GoTo Exit_Routine
        Dim req As New cHttpRequest
        With req
            .SetTimeouts 500, 500, 500, 500
            .Open_ "POST", Url, False
            .SetRequestHeader "Content-Type", "application/json"
            .Option_(WinHttpRequestOption_SslErrorIgnoreFlags) = 13056 '&H3300
            .Send
            MsgBox .ResponseText
            If .ResponseText = "" Then
            Else
            WebBrowser1.Navigate "about:blank"
            DoEvents
            WebBrowser1.Document.write .ResponseText
            End If
        End With
        Set req = Nothing
      
    Exit Function
    Exit_Routine:
    MsgBox Err.Description
    Exit Function
      
    End Function
    
    Function GetWinHttpRequest(ByVal Url As String) As String
        On Error GoTo Exit_Routine
        Dim req As New WinHttp.WinHttpRequest
        With req
            .SetTimeouts 500, 500, 500, 500
            .Open "POST", Url, False
            .SetRequestHeader "Content-Type", "application/json"
            .Option(WinHttpRequestOption_SslErrorIgnoreFlags) = 13056 '&H3300
            .Send
            MsgBox .ResponseText
            If .ResponseText = "" Then
            Else
            WebBrowser1.Navigate "about:blank"
            DoEvents
            WebBrowser1.Document.write .ResponseText
            End If
        End With
        Set req = Nothing
      
    Exit Function
    Exit_Routine:
    MsgBox Err.Description
    Exit Function
      
    End Function
    
    Private Sub Command1_Click()
        GetWinHttpRequest (Text2.Text)
    End Sub
    
    Private Sub Command2_Click()
        GetHTTPResponseHTTPS (Text2.Text)
    End Sub
    Note : On another Win10 (without VB6 installed), I get a "Classe non enregistrée" (Not registered class ?) error.

    For the software I would use this feature, I use an installer script (NSIS), so I added the HttpRequest.dll registration in the same way of another dll registration in the script, and once I installed the software through the installer, the code above is now ok winouth error on XP, 7 and 10 (which have not VB6 installed).
    Now rest me to adapt the test code to the real project, but I think it will be OK.

    Otherwise, I got the same result by registering the dll on a fresh windows, with regsvr32 "path_of_dll" (should recommended in C:\Windows\System32\ directory, or C:\Windows\SysWOW64\ for 64 bits windows version - This is the directory where has been copied the dll with NSIS script that refer to "$SYSDIR" environement variable).

    Thanks again for your great help

    I'll mark as resolved once the project modifed with the dll.

    1 Hour vinyl mix live on Eurodance90 each sunday 10:00 PM (French Timezone) - New non-official Jingle Palette update Jingle Palette Reloaded

  7. #7

    Thread Starter
    Hyperactive Member Couin's Avatar
    Join Date
    Dec 2020
    Posts
    270

    Re: Get simply html page from https URL, on XP and 7 ?

    Hi,

    Now it's OK with the dll implented in the project

    Just another question, I think it could be related.

    I would download an exe file, I tried some code :

    Code:
    Public Sub downloadTheFile(Url As String)
    
    1         On Error GoTo Exit_Routine
    
    2         Open App.Path & "/MyDownloadedFile.exe" For Binary As #1
            
              Dim req As New cHttpRequest
              
    3         With req
    4             .Open_ "POST", Url, False
    5             .Option_(WinHttpRequestOption_SslErrorIgnoreFlags) = 13056 '&H3300
    6             .Send
    7             Put #1, , .ResponseText
    8             Close #1
    9         End With
    10        Set req = Nothing
    
    11        Exit Sub
    Exit_Routine:
    12        Debug.Assert False
    13        ErrorLog Me.Name & ".Form_Resize"
    14        Resume Exit_Routine
    End Sub
    I call it by clicking on a CommandButton.

    Result :
    Sometimes it just cream a MyDownloadedFile.exe but its size is 0 kb, sometimes the file has a size but different of the original filesize (and of course, the file is wrong).

    With a txt file, it looks OK. With jpg file, it's wrong.

    Some idea ?

    Thanks !


    (Also, I would know if there is some info that returns % of downloaded datas ?)
    1 Hour vinyl mix live on Eurodance90 each sunday 10:00 PM (French Timezone) - New non-official Jingle Palette update Jingle Palette Reloaded

  8. #8
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,094

    Re: Get simply html page from https URL, on XP and 7 ?

    Try using ResponseBody property to fetch a byte-array if you are dealing with binary files/response.

    cheers,
    </wqw>

  9. #9

    Thread Starter
    Hyperactive Member Couin's Avatar
    Join Date
    Dec 2020
    Posts
    270

    Re: Get simply html page from https URL, on XP and 7 ?

    Hi

    Thanks, it works, for exe as for jpg

    About progress bar, I found this code https://www.vbforums.com/showthread....=1#post3462900 and tested with a sample project and your dll, works too
    Have now to implement in my project.
    1 Hour vinyl mix live on Eurodance90 each sunday 10:00 PM (French Timezone) - New non-official Jingle Palette update Jingle Palette Reloaded

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width