Sign in to follow this  
Followers 0
Wizzel

Reading Text From Web Browser

16 posts in this topic

Hi, I am trying to have AutoIt read a variable number from Firefox. For example, AutoIt would look onto a webpage and look for the number of people online, represented by a number that is changing. If there are over 5 people, it would do something, otherwise, it would wait 5 minutes and try again. This is not what I am doing specifically, but it is the most simple way I could describe what I am after. Imagine I was writing a program that would monitor stock numbers. The script would refresh the window until it detected the number is above say 100 and then it would sell. Is there any support for browsers in AutoIt?

Hope I explained my question correctly. Thank you.

-Wizzel

Share this post


Link to post
Share on other sites



_INetGetSource () would probably help you along in your search. You'd have to search through the source until you finds where it tells you... For more information look in the helpfile for the function I said...


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites

Why don't you use IE.au3

Share this post


Link to post
Share on other sites

Why don't you use IE.au3

What is this? Is it an internet explorer script or plugin? Thank you.

Share this post


Link to post
Share on other sites

It is a UDF that use Internet Explorer COM that uses DOM which allows you to control many different things in Internet Explorer. I recommend going to the help file and type _IE to get the section where the functions are located.

Share this post


Link to post
Share on other sites

It is a UDF that use Internet Explorer COM that uses DOM which allows you to control many different things in Internet Explorer. I recommend going to the help file and type _IE to get the section where the functions are located.

Awesome. It opens up a web browser, goes to the website, enters a username and password, logs me in. Now I need to know if there is a function to search for certain words. Say "new message". If it finds that, it will do something. Also, if there anyway to look for the value of messages. For example. If it says new messages: 16, is there any way to have it read the number 16?

Thank you.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Awesome. It opens up a web browser, goes to the website, enters a username and password, logs me in. Now I need to know if there is a function to search for certain words. Say "new message". If it finds that, it will do something. Also, if there anyway to look for the value of messages. For example. If it says new messages: 16, is there any way to have it read the number 16?

Thank you.

I have made some progress. Since I can't figure out how to get it to find a string and confirm a string exists and its value. Imaging that when you visited a website, it had four different strings of text it could give you. You only wanted one however. So it would search for the string, and then if it didn't find it, refresh and if it did, it would do something else. Another easy way to explain it with the same concept would be for a macro to figure out a specific number on a website. In other words, if you could make a macro that would search for the number 211 on this thread and return whether it is on this page, that would be exactly what I am looking for. Thank you.

Edited by Wizzel

Share this post


Link to post
Share on other sites

Something like this:

$sText = _IEBodyReadText($oIE)
If StringInStr($sText, "211") Then
   ;;; I found it
    _IEAction($oIE, "refresh")
Else
   ;;; didn't find it
   ;;; do something else
EndIf

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

Something like this:

$sText = _IEBodyReadText($oIE)
If StringInStr($sText, "211") Then
  ;;; I found it
    _IEAction($oIE, "refresh")
Else
  ;;; didn't find it
  ;;; do something else
EndIf

Dale

Thanks so much man. You appear to be the final word on a lot of Internet Explorer script with your awesome plugin. I have been searching the forums and have used a lot of your examples to construct code for this project. My last step is a tiny bit more complicated. It deals with variable prices of things. For example, it may say Bananas: 104 when I load the page. When I refresh it, it may say Bananas: 13. I need a way to grab the variable number of price. I am not completely useless, just at a loss for how to do this. Maybe, search for the string Bananas and then move over a certain amount of characters to the right and save that number as a variable. I know this is difficult. Thanks again for your help.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Thanks so much man. You appear to be the final word on a lot of Internet Explorer script with your awesome plugin. I have been searching the forums and have used a lot of your examples to construct code for this project. My last step is a tiny bit more complicated. It deals with variable prices of things. For example, it may say Bananas: 104 when I load the page. When I refresh it, it may say Bananas: 13. I need a way to grab the variable number of price. I am not completely useless, just at a loss for how to do this. Maybe, search for the string Bananas and then move over a certain amount of characters to the right and save that number as a variable. I know this is difficult. Thanks again for your help.

If you know the coordinates of text, you can clickdrag the text, send ctrl+c(copy to clip) and and set a var to $var = clipget() and use that accordingly

like in this shitty code of mine:

$iwantthis = "banana"

MouseClickDrag("left", 370, 215, 460, 215) ; copies the text in question (taht you painted blue with clickdrag)

Send("^c") ; sends ctrl+c (copy to clip)

$clip = ClipGet() ; sets variable $clip to "copied text"

If StringRegExp($clip, $iwantthis) = 1 Then ; if there is "banana" in the text then do..

Do stuff..

Endif

Edited by wictro

Share this post


Link to post
Share on other sites

Thanks so much man. You appear to be the final word on a lot of Internet Explorer script with your awesome plugin. I have been searching the forums and have used a lot of your examples to construct code for this project. My last step is a tiny bit more complicated. It deals with variable prices of things. For example, it may say Bananas: 104 when I load the page. When I refresh it, it may say Bananas: 13. I need a way to grab the variable number of price. I am not completely useless, just at a loss for how to do this. Maybe, search for the string Bananas and then move over a certain amount of characters to the right and save that number as a variable. I know this is difficult. Thanks again for your help.

If you are fortunate, the labels and numbers will be in a <table> (check this with DebugBar or look at the source). If so, take a look at _IETableWriteToArray and pull your values out of the array returned.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

This is where the info is stored.

CODE
<table>

<tr>

<td><img src="www.eqclassic.org/ss/1b.jpg" /></td>

<td width="3"></td>

<td valign="top">

<font size="2">

<b>Bananas</b><br />

Price/barrel: $105 </font>

</td>

</tr>

If I needed to figure out the price of the Bananas per barrel, and there is no simple way to do it, could I create an equation of something like:

Find "Bananas Price/Barrel: $(<40) to return a true statement if the price is less than 40. Or would I have to basically include every possible combination. If find string Bananas Price/barrel: $1, then, and so one with $2, and $3. But there has to be an easier way. That would take hundreds of lines of code. Thank you again DaleHorn.

Share this post


Link to post
Share on other sites

The data you want is in a tble, so that's a good thing. Unfortunately the label and value are in the same cell, so it is slightly harder than it could be.

Still, please practice with _IETableWriteToArray in the helpfile and its examples. Then try to make it work on your page. Once it does, you'll be able to pull the label and the price out of an array value and then use String* functions to parse it into pieces you want.

Your value comparison logic should not be hard once you have the value isolated.

Give it a try. If you have trouble, post your code.

Dale


Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I am not even sure where to start. Again, I am not way asking for people to write the code for me, I just need a bit more help.

_IETableWriteToArray ( $o_object )

This obviously needs an object. Is that the table name or what? Where can I find the table name? Once I have it, it reads it into an array. With that array, I can isolate the number, correct? Any idea how to specifically do that. There are other things in the table too, and I need to make sure it only pick the value of say bananas. One I have it isolated to an array, which command should I use. Again, i am asking for help, not for you to do this for me. I can only try to understand the frustration you all must endure with people who simply want scripts written and people who don't read the FAQ and helpfiles. I have read both but am still new to this. For an example of needing to isolate just the cost of Bananas in a table with Apples too,

CODE
<table>

<tr>

<td><img src="mg src="www.eqclassic.org/ss/1b.jpg" /></td>

<td width="3"></td>

<td valign="top">

<font size="2">

<b>Bananas</b><br />

Price/barrel: $105 </font>

</td>

</tr>

<tr>

<td><img src="www.eqclassic.org/ss/2b.jpg" /></td>

<td width="3"></td>

<td valign="top">

<font size="2">

<b>Apples</b><br />

Price/barrel: $144 </font>

</td>

</tr>

</table>

Edited by Wizzel

Share this post


Link to post
Share on other sites

If you know the coordinates of text, you can clickdrag the text, send ctrl+c(copy to clip) and and set a var to $var = clipget() and use that accordingly

like in this shitty code of mine:

$iwantthis = "banana"

MouseClickDrag("left", 370, 215, 460, 215) ; copies the text in question (taht you painted blue with clickdrag)

Send("^c") ; sends ctrl+c (copy to clip)

$clip = ClipGet() ; sets variable $clip to "copied text"

If StringRegExp($clip, $iwantthis) = 1 Then ; if there is "banana" in the text then do..

Do stuff..

Endif

I can use this as a backup plan. Sounds pretty good. Would like to do it more simply though if possible.

Share this post


Link to post
Share on other sites

Okay, I made some progress. It opens the web browser, logs me in and then tries to navigate to another page, once logged in. I get errors. Here is my code. Probably a simple error, but I am just learning.

CODE
While $login = 2

_IELoadWait ($oIE)

_IENavigate ($oIE, "www.eqclassic.org")

$login = 2

$check = 1

Wend

The navigate and load wait are giving me errors.

--> IE.au3 V2.3-1 Error from function _IELoadWait, $_IEStatus_InvalidDataType

--> IE.au3 V2.3-1 Error from function _IENavigate, $_IEStatus_InvalidDataType

Thanks...

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  
Followers 0