Jump to content

Recommended Posts

Posted

I am looking to create a script which refreshes/reads a webpage every few seconds. My goal is to see if the page has changed, then I will send myself a notification that the webpage has been updated.

 

However, rather than downloading the entire webpage every single time, is there a way to check when the webpage last updated?

 

If not, is there away to partially download/read html source until a specific tag is hit?

 

Goal: I would like to increase my poll rate and not excessively waste data.

Posted

There is multiple ways to achieve this.  Provide the URL of the page.  And show DOM of the specific part of the page you want to monitor.  What is it that you need to look for ?

Posted (edited)

Do you want to use IE or WebDriver , Which browser ?

Edited by mLipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

Spoiler

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 SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST APIErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *

 

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane

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 * Good coding practices in AutoIt * 

OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX

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 * _IEquerySelectorAll() (by uncommon) * IE in TaskSchedulerIE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related:How to get reference to PDF object embeded in IE * IE on Windows 11

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 *

I also encourage you to check awesome @trancexx code:  * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuffOnHungApp handlerAvoid "AutoIt Error" message box in unknown errors  * HTML editor

winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/

"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."

Signature last update: 2023-04-24

Posted
5 minutes ago, Pured said:

I'm not sure how to find a page's dom

Just right click on an element of the web page and select "Inspect" in the context menu.

If you are looking at any change in a page, it would be quite easy to do with a generic solution.  If you looking for a specific change in a specific tag (or part of the web page), I am afraid it is going to be very hard to find a generic solution.  You will need to adapt your code to each individual page.

Posted

@Nine Going through this forum, I know I can get the size of a page, but it seems like I have to download the entire page rather than just fetch the size.

 

It would be nice if there is a way to fetch the date modified or size of a webpage without getting anything else, since I don't care too much about what has changed (I hope...). 

 

Otherwise like you said, using doms (I have other scripts which traverse through html and to tag-specific jobs), so I can do that myself, but it would require a full load of the page, which I don't want.

Posted (edited)
4 hours ago, Pured said:

It would be nice if there is a way to fetch the date modified or size of a webpage without getting anything else, since I don't care too much about what has changed

@Pured

If that is all you want, then just retrieve the web page's header.  That will only include information about the page and not the page itself.  The Content-Length header will give you the size of the content or if it exists, you can look for the Last-Modified header.  Depending on the framework used by the web page, looking at those headers may not be a very accurate way to tell if the content has changed.

There are several ways to get just the header.  If I were looking for the header, then an easy way would be to execute a simple cURL command or send a HTTP HEAD request using one of the numerous ways to do HTTP requests.

Example header:

HTTP/2 200
server: nginx
date: Tue, 06 Apr 2021 13:44:06 GMT
content-type: text/html;charset=UTF-8
content-length: 198416
vary: Accept-Encoding
x-powered-by: PHP/7.2.34
x-ips-loggedin: 0
vary: cookie,Accept-Encoding
x-xss-protection: 0
x-frame-options: sameorigin
expires: Tue, 06 Apr 2021 13:45:06 GMT
cache-control: max-age=60, public
pragma: public
set-cookie: ips4_IPSSessionFront=lfntg0ifj1a53lnh9s4vvvndpt; path=/; secure; HttpOnly
set-cookie: ips4_guestTime=1617716646; path=/; secure; HttpOnly
last-modified: Tue, 06 Apr 2021 13:44:06 GMT
x-powered-by: PleskLin

 

13 hours ago, Pured said:

Goal: I would like to increase my poll rate and not excessively waste data.

Be warned, continuously "banging" on a website, very frequently, will most likely get your IP address blocked if the host has any type of decent anti-hammering protection.  That type of behavior is usually frowned upon.  😉

 

Edited by TheXman
  • 2 weeks later...
Posted

Dear 

i am new in Http API and i need your support 

i try this code but it did not gave me the head.

by the way this page need user ID and Password.

#include "WinHttp.au3"

Opt("MustDeclareVars", 1)

; Open needed handles
Global $hOpen = _WinHttpOpen()
Global $hConnect = _WinHttpConnect($hOpen, "https://intranet.airlineretailing.amadeus.com:55001")
; Specify the reguest:
MsgBox(0, " $hConnect",  $hConnect)    ;" works gave ID"
Global $hRequest = _WinHttpOpenRequest($hConnect, Default, "/1ASIHGAPSV/arp/index.html")
MsgBox(0, "$hRequest",  $hRequest)       ;" works gave ID"
; Send request
_WinHttpSendRequest($hRequest)

; Wait for the response
_WinHttpReceiveResponse($hRequest)

; Get full header
Global $sHeader = _WinHttpQueryHeaders($hRequest)

; Close handles
_WinHttpCloseHandle($hRequest)
_WinHttpCloseHandle($hConnect)
_WinHttpCloseHandle($hOpen)

; Display retrieved header
MsgBox(0, "Header", $sHeader)

 

Thank

Posted (edited)

@samibb

You've been on this forum long enough to know better than to try to "hijack" a thread with your unrelated issues.  If you have questions about using the WinHTTP.au3 functions, then post your questions in the WinHTTP UDF topic or start a new one.

As it relates to the example that you posted, if you added @error checking then you would have seen that the _WinHttpReceiveResponse failed.  The most likely reason that it failed is because you tried to send an https request without using the $WINHTTP_FLAG_SECURE flag in your _WinHttpOpenRequest.

Look at the reply below for an example of a _WinHttpOpenRequest that is setting up a secure request using WinHTTP.  Note that you were a member of this topic.  :think:  There are numerous other examples of sending https requests using the WinHTTP UDF lib.

here's another one that gives a brief explanation of why you need the flag for secure connections:

If you have additional questions, then post them in a proper topic, not one that is asking about how to "partially read a webpage".

Edited by TheXman

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
×
×
  • Create New...