Jump to content

Grabbing TEXT only from website


d0n
 Share

Recommended Posts

What i want to do is get a bunch of numbers from a website, to do some calculations with

heres the source for the website

and the part i want to get is this

<td><img src="img/un/r/1.gif" width="18" height="12" border="0"></td>

<td>Lumber:</td><td align="right"><b>400 </b></td><td> per hour</td>

</tr>

<tr>

<td><img src="img/un/r/2.gif" width="18" height="12" border="0"></td>

<td>Clay:</td><td align="right"><b>370 </b></td><td> per hour</td>

</tr>

<tr>

<td><img src="img/un/r/3.gif" width="18" height="12" border="0"></td>

<td>Iron:</td><td align="right"><b>310 </b></td><td> per hour</td>

</tr>

<tr>

<td><img src="img/un/r/4.gif" width="18" height="12" border="0"></td>

<td>Crop:</td><td align="right"><b>205 </b></td><td> per hour</td>

bolded = the numbers i need, and they will change through time

dorf1.php

Edited by d0n
Link to comment
Share on other sites

Since your data is in a table, check out _IETableWriteToArray (search the helpfile and then look at the examples).

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

Link to comment
Share on other sites

What i want to do is get a bunch of numbers from a website, to do some calculations with

heres the source for the website

and the part i want to get is this

<td><img src="img/un/r/1.gif" width="18" height="12" border="0"></td>

<td>Lumber:</td><td align="right"><b>400 </b></td><td> per hour</td>

</tr>

<tr>

<td><img src="img/un/r/2.gif" width="18" height="12" border="0"></td>

<td>Clay:</td><td align="right"><b>370 </b></td><td> per hour</td>

</tr>

<tr>

<td><img src="img/un/r/3.gif" width="18" height="12" border="0"></td>

<td>Iron:</td><td align="right"><b>310 </b></td><td> per hour</td>

</tr>

<tr>

<td><img src="img/un/r/4.gif" width="18" height="12" border="0"></td>

<td>Crop:</td><td align="right"><b>205 </b></td><td> per hour</td>

bolded = the numbers i need, and they will change through time

Read the help on all the string functions. The first AI project I did was similar to this and was very easy to learn. Your digits would be very easy to extract and equate.

Link to comment
Share on other sites

Read the help on all the string functions. ...

Or replicate the example for _IETableWriteToArray -- job done in 4 lines of code :P

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

Link to comment
Share on other sites

align="right"><b>

Its easier than you think. Each number you are looking for is preceded by the above. I do it the hard way but it works....here is an example of how I search for a quote in a website.

script follows........

$filedir = "C:\AA TASKBAR SHORTCUTS\Desk\Hold Basket\Word.txt"

$pos1= 0

$pos2= 0

$word = ""

$line = ""

;Local $o_speech = ObjCreate ("SAPI.SpVoice") *disabled

;$o_speech.Speak("Here is your quote for today") *disabled

$rssfeed = "http://wordsmith.org/words/today.html"

InetGet($rssfeed, $filedir)

$file = FileOpen($filedir, 0)

while 1

$line = FileReadLine($file)

$pos1=stringinstr($line,"<quote>")

if $pos1>0 then start()

wend

func start()

while 1

$line = FileReadLine($file)

$line=stringreplace($line,"<p>","")

$word = $word & $line

$pos2 = StringInStr($line, "</quote>")

If $pos2 > 0 Then end()

WEnd

endfunc

Link to comment
Share on other sites

Sorry...I didn't post the entire script...here it is again.

$filedir = "C:\AA TASKBAR SHORTCUTS\Desk\Hold Basket\Word.txt"

$pos1= 0

$pos2= 0

$word = ""

$line = ""

$rssfeed = "http://wordsmith.org/words/today.html"

InetGet($rssfeed, $filedir)

$file = FileOpen($filedir, 0)

while 1

$line = FileReadLine($file)

$pos1=stringinstr($line,"<quote>")

if $pos1>0 then start()

wend

func start()

while 1

$line = FileReadLine($file)

$line=stringreplace($line,"<p>","")

$word = $word & $line

$pos2 = StringInStr($line, "</quote>")

If $pos2 > 0 Then end()

WEnd

endfunc

Func end()

splashtextOn("Quote For The Day",$word)

FileClose($file)

Exit

EndFunc

Link to comment
Share on other sites

I am having a little trouble with this line

$oTable = _IETableGetCollection ($oIE, -1)

i don't know what should be the $i_index for my table, how do i find that out?

They are numbered sequentially starting with 0. You can look at the source and count <TABLE> tags to get to the one you want (0, 1, 2, 3 etc) then replace the -1 with that number.

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

Link to comment
Share on other sites

its the 5th one i checked but when i run this code the msgbox shows nothing

#include <IE.au3>
$oIE = _IECreate ("http://s7.travian.com/dorf1.php")
$oTable = _IETableGetCollection ($oIE, 5)
$aTableData = _IETableWriteToArray ($oTable)
MsgBox(0, "Frame Info", $aTableData)
Link to comment
Share on other sites

its the 5th one i checked but when i run this code the msgbox shows nothing

#include <IE.au3>
$oIE = _IECreate ("http://s7.travian.com/dorf1.php")
$oTable = _IETableGetCollection ($oIE, 5)
$aTableData = _IETableWriteToArray ($oTable)
MsgBox(0, "Frame Info", $aTableData)
$aTableData is a 2-D array - the data needs to be accessed by index, $aTableData[$i][$j] (e.g. $aTableData[0][3]).

This recent post shows an example of just what you are trying to do and then looping through the array and writing the values to a comma-separated file.

Dale

Edit: Also note, if it is the 5th <TABLE> tag, you want to use 4 and not 5 since the numbering starts with 0

Edited by DaleHohm

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

Link to comment
Share on other sites

sorry index 5 not 5th one :P

#include <IE.au3>
$oIE = _IECreate ("http://s7.travian.com/dorf1.php")
$oTable = _IETableGetCollection ($oIE, 5)
$aTableData = _IETableWriteToArray ($oTable)
MsgBox(0, "Frame Info", $aTableData[0][1])

still doesn't show me anything in the box tho

Link to comment
Share on other sites

0, 1 could be an empty cell.

Try the example in the other post I pointed you to. Try it with the example from the helpfile as well so that you can see how it is supposed to work.

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

Link to comment
Share on other sites

when i run it with index 5 i get this

0,0,0,0

Lumber:,Clay:,Iron:,Crop:

none

but it doesn't work when i run on index 6

Posted Image

#include <IE.au3>
$oIE = _IECreate ("http://s7.travian.com/dorf1.php")
$oTable = _IETableGetCollection ($oIE, 6)
$aTableData = _IETableWriteToArray ($oTable)

Local $i = 0, $j = 0, $line
Local $iMax = Ubound($aTableData, 0) - 1, $jMax = Ubound($aTableData, 1) - 1

For $i = 0 To $iMax
    $line = ""
    For $j = 0 to $jMax
        $line &= $aTableData[$i][$j]
        If $j = $jMax Then
            FileWriteLine("book1.txt", $line)
        Else
            $line &= ","
        EndIf
    Next
Next
Link to comment
Share on other sites

huh?

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

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