Jump to content
Sign in to follow this  
iCode

InetRead() - inconsistent results

Recommended Posts

iCode

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)

Share this post


Link to post
Share on other sites
water

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 (2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2018-09-01 - Version 1.3.4.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
iCode

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)

Share this post


Link to post
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
Sign in to follow this  

×