Jump to content

Keeping track of dynamic webpage content with IE.au3


Newb
 Share

Recommended Posts

Hi,

So, I'm doing a script that monitors a wesite stats that are dislocated in multiple pages. Once those statistics are read (Plain text in every webpage) they are feed to a variable and then Placed into the GUI with a GuiCtrlSetData command.

So to make it simple, I have to read text placed into multiple pages and bring it all simultaneously to the GUI, while an object in the Gui displays ONLY the main page of the site and the others are read hidden.

Why Dynamic? Because it changes every few minutes, and so i need to check those pages periodically.

Example: I have 3 pages, in one I have the date "30/01/2011", In one I have number of visits: "Today's visit 3923", in the third I have another stat: "Most Visitors came from: Austria"

And I want a gui with with written on: 30/01/11, 3923 visits, mostly from Austria.

I already know how to fetch text, what i want to know is how to read all the three pages togheter.

I thought about making multiple objects into the same gui like this:

Global $oIE = ObjCreate("Shell.Explorer.2")
Global $oIE2= ObjCreate("Shell.Explorer.2")
$GuiMAIN = GUICreate("MysiteStats", 802, 617, 213, 139)
Global $Obj = GUICtrlCreateObj($oIE,  304, 8, 489, 585)
Global $Obj2 = GUICtrlCreateObj($oIE2,  304, 8, 2, 2)
$oIE.navigate("http://site.com/page1.html")
$oIE2.navigate("http://site.com/page2.html")
;String fetching code down here

But it seems to mess up a little, still have to do several tests though. Was hoping some of you could give me some hints, to know if this is possible, or if you suggest other methods.

I don't want to use WinHTTP.au3 because i don't know it and it's too hard for me. I've already tried to just create the object Shell.Explorer.2 without putting it into an object with GuiCreateObj and just navigating it, but it seems to not work.

Any help?

PS: Sorry if i repeated it more than once, but i wanted to be very specific and to make it the clearest possible

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Why not just use _INETGetSource to get the source code, and use StringBetween to get the specific stuff.

Well, also thought of that. Gotta give a try that way. I've experimented a lot with that Multi Object GUI and so I just wanted to know if it was possible.

Edit: Looked at the function you suggestes. I think I will do all the work with it :P

Anyway, I'm still curious about that thing of multiple gui objects, if anyone knows, please inform me :x

Looked

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

You don't read all 3 pages at the same time. That would require multiple threads. Simply read them one after the other. If you don't want your customers to see your GUI update one field at a time, then simply store the values from the webpage in some variables and display them all at once when they are all loaded.

There is a way around your problem. But the extra work is not nearly worth it.

Link to comment
Share on other sites

The fact is that I need all of them in the same moment. So, Inetgetsource seems to do the work, as it can get the source quickly from all of the three pages. Doing it with multiple threaded Objects might be cumbersome, but that what I was asking, I needed them all in the same moment or by the way by don't switching in any way the page displayed in the main GUI. Inetgetsource will do it.

Glad to see that there is a workaround for that anyway. Just for the sake of learning, if it doesn't bother you, what is the workaround?

EDIT: need to know another thing, there is a way to remove html tags from the output of Inetgetsource and get the plain text of a page (i mean a script made by someone or whatever function, not writing a string remover myself)?

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

No one ever said you had to reuse the same window to load the other pages. In fact, you even said yourself that the main page has to be displayed the whole time. To me the logical step is to create extra windows, not visible, to load the webpages. In the example I forgot the include and to not make them visible in _IECreate.

; Set up pages
$oIE1 = _IECreate("http://pageone.com")
$oIE2 = _IECreate("http://pageone.com")
$oIE3 = _IECreate("http://pageone.com")

; At this point in time, the 3 pages are all loading (real concurrency)

; Wait for all pages to finish loading because we need all of the results
_IELoadWait($oIE1)
_IELoadWait($oIE2)
_IELoadWait($oIE3)

; Read all html
$page1 = _IEBodyReadHTML($oIE1)
$page2 = _IEBodyReadHTML($oIE2)
$page3 = _IEBodyReadHTML($oIE3)
Edited by Manadar
Link to comment
Share on other sites

For what concerns the html tags stripping, i found this

With a good regex (gotta learn to regex!) that does the work.

For what concerns windows, there must be an argument to make them invisible, yeah.

Well, anyway, I managed to solve it. Thanks

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

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