Sign in to follow this  
Followers 0
dvlkn

Copying html table

9 posts in this topic

#1 ·  Posted (edited)

Hello

I am having another web page manipulation issue again ;) This time I want to copy a html table and paste it in notepad for e.g.

$oFrame = _IEFrameGetObjByName ($oIE, "main")

$oTable = _IETableGetCollection ($oFrame, 6)

clipPut ($oTable)

WinActivate ("Untitled - Notepad")

Send ("^v")

Would this work ? Because for now, it's only pasting a "0" in my notepad file and I wonder maybe clipPut cannot not "work" with that data ? Or I could be picking the wrong table so I am trying every numbers at the moment :D

Any help appreciated

Edited by dvlkn

Share this post


Link to post
Share on other sites

$oTable is an object reference variable, not the table content

See _IEPropertyGet -> innerText or innerHTML

Better yet, you should probably use _IETableWriteToArray

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

I see, thanks for pointing me in the right direction. As for the array, is there a limit to the amount of data that can be written to it ? And suppose I need to perform arithmetic operations and wish to display it alongside the copied/pasted table, would that be possible ?

Share this post


Link to post
Share on other sites

Try it and ask questions you may have as a result.

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

#6 ·  Posted (edited)

OK is there another way to capture a html table from a web page ? Because if I use any of the functions above, the data comes out just as plain text i.e. it loses its "table alignment"

I don't want to use the _IEwritetoarray as well because there is simply too much data to work with. I gotta send it to a spreadsheet like excel for e.g.

Edited by dvlkn

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Working with the array should not be that tough.

This approach may be what you are looking for however:

#include <IE.au3>
$oIE = _IE_Example("table")
$oTable = _IETagnameGetCollection($oIE, "table", 0)
$sTable = _IEPropertyGet($oTable, "outerhtml")

$oIE2 = _IECreate()
_IEBodyWriteHTML($oIE2, $sTable)
_IEAction($oIE2, "selectall")
_IEAction($oIE2, "copy")
ClipGet()
; you can now paste into Excel

If you want to avoid a secutiry warning about script accessing your clipboard, you may wnat to use SEND commands with ^a ^c instead of the _IEAction functions.

Dale

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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

That works nicely, thank you. I tried a bit more with the 2D array like you advised me... my problem is that I have to copy several tables from the web, not just one. How can I add the following tables to the same array ? I fooled around with the _ArrayAdd function but to no avail :)

*edit*

I need to be more explicit. I have like 80 html tables I want to copy. So far, my table.au3 correctly logins, navigate to the page, parse the html table and write it to the array. Now I am trying to make it continue to navigate to the next page and thus the desired table & add it to the array.

Each table has 20 rows.

Edited by dvlkn

Share this post


Link to post
Share on other sites

Suggest you open a new topic to discuss your array management questions.

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

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