Sign in to follow this  
Followers 0
anyday

Pull Text From Website And Insert Into Listbox?

9 posts in this topic

hey guys im back again :).

im trying to figure out if it is possible to get text from the source of a website and insert it into a listbox as records?

example:

Source code of website:

<td align=middle><font class=fdata><small>TN</small></font></td>
                  <td align=middle><font class=fdata><small>QUOTE NAME HERE</small></font></td>
                  <td align=middle><font class=fdata><small>-</small></font></td>
                  <td align=middle><font class=fdata><small>11/16/2004</small></font></td>
                  <td align=middle><font class=fdata><small>350</small></font></td>

is there anyway that i could grab this info and have it display as one record in a gui . i dont know what would be the best to display in wether it be a listbox, combobox, listview. Just trying to figure out if this is possible.

an example of the output in gui would be like

State Client Effective Date Premium

TN Quote Name Here 11/16/2004 350

Share this post


Link to post
Share on other sites



#include <array.au3>
Global $StringStuff[6]
$string = "<td align=middle><font class=fdata><small>TN</small></font></td>" & @CRLF & _ 
"<td align=middle><font class=fdata><small>QUOTE NAME HERE</small></font></td>" & @CRLF & _ 
"<td align=middle><font class=fdata><small>-</small></font></td>" & @CRLF & _ 
"<td align=middle><font class=fdata><small>11/16/2004</small></font></td>" & @CRLF & _ 
"<td align=middle><font class=fdata><small>350</small></font></td>"
$FirstSplit = StringSplit($string, @CRLF, 1)
For $i = 1 To $FirstSplit[0]
    $StringStuff[$i] = StringTrimLeft (StringTrimRight ($FirstSplit[$i], StringLen ("</small></font></td>")), StringLen ("<td align=middle><font class=fdata><small>"))
Next
_ArrayDisplay ($StringStuff, "whee")

Share this post


Link to post
Share on other sites

thanks man that works good, now the next problem is i gotta figure out a way to set $string = to get it from the html source.

i could do $string = _IEBodyReadHTML() but that would get the whole document. i need to only load the certain strings and there could be more than 1

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Global $YourString[6]
$Array = StringSplit (_IEBodyReadHtml($IEobj), "<td align=middle><font class=fdata><small>", 1)
For $i = 2 to 6
$YourString[$i-1] = StringTrimRight ($Array[$i], StringLen ("</small></font></td>" + 2))
Next

Assuming the first occurrence of "<td align=middle><font class=fdata><small>" is what you want (there aren't others in the source that would mess up the stringsplit), this should work.

Edited by greenmachine

Share this post


Link to post
Share on other sites

would you think a listbox would be the best way to display it in a gui?

Share this post


Link to post
Share on other sites

would you think a listbox would be the best way to display it in a gui?

A listview, yes. You can make multiple colums to show the data, and then a listviewitem for each entry.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

thanks for the help. you wouldnt happen to know if it is possible to resize a IE window to a specific resolution with autoit?

has to do with this script.

i looked through the functions and macros i see stuff to maximize but no resize.

Edited by anyday

Share this post


Link to post
Share on other sites

thanks for the help. you wouldnt happen to know if it is possible to resize a IE window to a specific resolution with autoit?

has to do with this script.

i looked through the functions and macros i see stuff to maximize but no resize.

WinMove()?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Global $YourString[6]
$Array = StringSplit (_IEBodyReadHtml($IEobj), "<td align=middle><font class=fdata><small>", 1)
For $i = 2 to 6
$YourString[$i-1] = StringTrimRight ($Array[$i], StringLen ("</small></font></td>" + 2))
Next

Assuming the first occurrence of "<td align=middle><font class=fdata><small>" is what you want (there aren't others in the source that would mess up the stringsplit), this should work.

i get the following error with this code.

If IsObj($o_object.document) Then
If ^ ERROR

Error: The requested action with this object has failed.

what i think is going on is the website i have to goto to get this information loads a popup window with the data i am trying to get out. does that mean that $oIE would not be my variable anymore for the browser window?

Thanks smoke n for the tip worked perfect.

Edited by anyday

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