Jump to content

InetRead() - inconsistent results


iCode
 Share

Recommended Posts

I'm getting inconsistent results with InetRead/_INetGetSource and wondering why

The problem seems to be specific to certain websites, in this instance rt.com

Here's the sample code...

#include <Inet.au3>

$url = "http://rt.com/news/ukraine-right-sector-militants-210/"
$str = InetRead($url, 3)
;$str = _INetGetSource($url, True)
ConsoleWrite("@error=" & @error & @LF)
ConsoleWrite(BinaryToString($str, 4) & @LF)
;ConsoleWrite($str & @LF)

Without changing anything at all, sometimes InetRead() will return a string, and sometimes it doesn't

@error is always 0 either way

When it doesn't return the expected string, it returns "US?BS", which is actually  some sort of encoded character(s) i believe

I've tried using BinaryToString() with 1, 2, 3 and 4 and though i've never gotten a string with 2 and 3, i have with 1 and 4, but again, the results are not consistent - sometimes it will return the expected string several times in a row, and then it won't for several times in a row

I think it would be better in my case to not depend on IE since i need reliable results, so if anyone has any suggestions for downloading a file via http/https, i'd appreciate it. I am aware of wget for windows, but if there is a self-contained executable without the dependencies, i would prefer that

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

Link to comment
Share on other sites

Have you tried

$str = InetRead($url, 1)
because as you do not use HTTPS there is no need to ignore SSL erros. Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I just tried it and it makes no difference

FUNCTIONS: WinDock (dock window to screen edge) | EditCtrl_ToggleLineWrap (line/word wrap for AU3 edit control) | SendEX (yet another alternative to Send( ) ) | Spell Checker (Hunspell wrapper) | SentenceCase (capitalize first letter of sentences)

CODE SNIPPITS: Dynamic tab width (set tab control width according to window width)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...