hi,i am trying for get hrml source of my special url "https://www.melkeirani.com/melk-225433".
my problem is about work on windows 7 and lower versions.
i attached my source and i need help to can fix it.
i designed 6 buttons for get source html with 6 different methods
my result on different windows are :
on windows 10 64bit :
button 2,button 3,button 5,button 6 worked
button 1 error : A connection with the server could not be established
on windows xp :
button 6 worked.
button 1,4 error : A connection with the server could not be established
button 2,3,5 error : The download of then specified resouce had failed.
on windows 7 64 bit :
button 6 worked.
button 1,4 error : A connection with the server could not be established
button 2,3,5 error : The download of then specified resouce had failed.
button 6 worked on all version windows and i used chilkat for button 6.
i searched in google about that errors and i find too many answered about use tls versions or install easy fix from microsoft and etc and i did try for fix errors but not solved yet.
i found other samples about downloaders or https connect but not worked on that windows 7 yet and same errors.
my important question is about button 6,if my windows hv problem or need special refrences or install some servicices packs or etc ... why button 6 worked on all .
i want jst one sample code to get source html to work on windows 7 and that my spcial url sample too.
button 1 source code :
button 2:Code:Dim ht As New WinHttpRequest ht.open "GET", "https://www.melkeirani.com/melk-225433", False ht.Option(WinHttpRequestOption_SslErrorIgnoreFlags) = SslErrorFlag_Ignore_All ht.Option(WinHttpRequestOption_SecureProtocols) = WinHttpRequestSecureProtocols.SecureProtocol_ALL ht.setRequestHeader "Accept-Charset", "utf-8" ht.setRequestHeader "Accept-encoding", "utf-8" ht.setRequestHeader "Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8" ht.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0" ht.send ht.WaitForResponse MsgBox ht.responseText Set ht = Nothing
button 3:Code:Dim http As New MSXML2.XMLHTTP60 Dim url As String url = "https://www.melkeirani.com/melk-225433" http.open "Get", url, False http.send MsgBox http.responseText
button 4 :Code:DownloadFile "https://www.melkeirani.com/melk-225433", App.Path & "\3.html"
button 5 :Code:Dim objHTTP As Object Set objHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") Dim url As String url = "https://www.melkeirani.com/melk-225433" objHTTP.open "GET", url, False objHTTP.Option(WinHttpRequestOption_SecureProtocols) = WinHttpRequestSecureProtocols.SecureProtocol_ALL objHTTP.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36" objHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded" objHTTP.send MsgBox objHTTP.responseText
button 6 : (sample chilkat)Code:Dim fso As Object Dim ShApp As Object Dim WshShell As Object Dim File As Object Dim BS As Object Set fso = CreateObject("Scripting.FileSystemObject") Set WshShell = CreateObject("Wscript.Shell") Set ShApp = CreateObject("Shell.Application") On Error Resume Next Set File = CreateObject("Microsoft.XMLHTTP") File.open "GET", "https://www.melkeirani.com/melk-225433", False File.setRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C; .NET4.0E; BCD2000; BCD2000)" File.send If Err.Number <> 0 Then MsgBox "Error " & Err.Number & "(0x" & Hex(Err.Number) & ") " & Err.Description MsgBox "Source " & Err.Source MsgBox "" MsgBox "HTTP Error " & File.Status & " " & File.statusText MsgBox File.getAllResponseHeaders Else On Error GoTo 0 Set BS = CreateObject("ADODB.Stream") BS.Type = 1 BS.open BS.Write File.responseBody BS.SaveToFile ShApp.Namespace(&H10).self.Path & "\5.html", 2 End If
Code:Dim req As New ChilkatHttpRequest Dim http As New ChilkatHttp Dim success As Long ' need acitve key replace with "..." 'success = http.UnlockComponent("...") If (success <> 1) Then MsgBox http.LastErrorText Exit Sub End If Dim localFilePath As String localFilePath = App.Path & "\6.html" success = http.Download("https://www.melkeirani.com/melk-225433", localFilePath) If (success <> 1) Then MsgBox "error : " & http.LastErrorText Exit Sub End If




Reply With Quote
