element72

What is a fast way to get specific html objects?

7 posts in this topic

#1 ·  Posted (edited)

I finished making a script to get element object information from various table columns with _INetGetSource and _StringBetween and StringRegExp. I put timers around my script and found out that _INetGetSource is the source of the slow downs. Could using IE udf be a lot leaner and faster?  Are there other ways that might be faster?

 

Edit: After some more forum searching and testing with IE.au3 library, I found that _IEBodyReadHTML and _IEDocReadHTML doesn't work unless you literally have an IE window open and loaded with the URL you want. I feel like that would take longer than _INetGetSource. I did read the difference between the 3 functions on another thread where Dale posted his explanation. Am I right about _IEBodyReadHTML and _IEDocReadHTML ? That it doesn't retrieve the sources unless you literally have an IE window open?

Edited by element72

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Could using IE udf be a lot leaner and faster?

No - it would be much slower. InetRead (which is used by _InetGetSource) retrieve only the source html-code of the requested page and leave it as is. The IE instead reads the source and look for additional content like images, css-files, javascript-files etc. and also loads this content. After that it renders all the stuff. So it has a lot more to load and work and so it can't be faster than a simple InetRead for getting the source code.

For demonstration a small speed comparison:

#include <IE.au3>

Global Const $N = 5
Global Const $s_URL = "https://www.whitehouse.gov/"


#Region get source code with InetRead
$iT = TimerInit()
For $i = 1 To $N
    $s_Source = BinaryToString(InetRead($s_URL, 1))
Next
$iT = TimerDiff($iT)
ConsoleWrite(StringFormat("% 20s: %8.3f ms\n", "InetRead", $iT / $N))
#EndRegion

#Region get source-code with IE
Global $oIE = _IECreate("about:blank", 0, 0, 0, 0)
$iT = TimerInit()
For $i = 1 To $N
    _IENavigate($oIE, $s_URL)
    $s_Source = _IEDocReadHTML($oIE)
Next
$iT = TimerDiff($iT)
ConsoleWrite(StringFormat("% 20s: %8.3f ms\n", "IE", $iT / $N))
_IEQuit($oIE)
#EndRegion

 

 

Edited by AspirinJunkie
1 person likes this

Share this post


Link to post
Share on other sites

:offtopic:
I like the way you use StringFormat. :)

 


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

Getting more speed

1. Get a faster internet connection

2. Switch to a compiled language

3. Cut out all the layers of frameworks and go to barebone HTTP protocol
   http://odetocode.com/Articles/741.aspx

I assume INetGetsource is still based on com object winhttp services 

https://msdn.microsoft.com/en-us/library/windows/desktop/aa384109(v=vs.85).aspx

    Const $sURL = "https://www.whitehouse.gov/"
    $oWinHttp = ObjCreate("WinHttp.WinHttpRequest.5.1")
    $oWinHttp.Open("GET", $sURL, false)
    $oWinHttp.Send()
    consolewrtie($oWinHttp.ResponseText)

Share this post


Link to post
Share on other sites

3. Cut out all the layers of frameworks and go to barebone HTTP protocol
   http://odetocode.com/Articles/741.aspx

It looks like another interesting article to read.


February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

Share this post


Link to post
Share on other sites

you should start on page 1 of the internet ;-)

1 person likes this

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

you should start on page 1 of the internet ;-)

You mean here:

http://info.cern.ch/ ??

 ;)

 

Edited by mLipok

February 26, 2017: New SciTE4AutoIt3 available with the updated SciTE v3.7.3 release
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  for other useful stuff click the following button:

Spoiler

Last update: 2017-02-26
Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. 

My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAPPOP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF * WinSCP UDF *

My contribution to others projects: * _sql.au3 UDF  *

Useful links: * Forum Rules * Forum etiquette *  Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * 

Wiki: Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Best coding practices * 

IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities *

I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions *  EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *

"Homo sum; humani nil a me alienum puto" - Publius Terentius Afer
"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"
:naughty:  :ranting:, be  :) and       \\//_.

Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty."

 

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