Jump to content

I can´t copy text from a webpage


Recommended Posts

Hi, i want to copy all the updates KB**** to a a text file from windows updates, but it does not copy me anything. Here is my script:

#include <IE.au3>

#include <String.au3>

#include <array.au3>

_IEErrorHandlerRegister()

$sURL = "http://update.microsoft.com"

$oIE = _IECreate($sURL, 1)

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

_IELoadWait($oFrame)

$oLink = _IELinkGetCollection($oFrame, 0)

_IEAction($oLink, "click")

$sText = _IEBodyReadText ($oFrame)

$aArray = _StringBetween($sText,"(KB",")")

If IsArray($aArray) Then

_ArraySort($aArray)

$iRetCode = _ArrayToClip( $aArray, 0 )

FileOpen("Test.txt", 2)

FileWrite("Test.txt", ClipGet())

Else

MsgBox(0, 'Empty', 'Nothing found')

EndIf

Edited by Delai
Link to comment
Share on other sites

The biggest problem I see is that there is a page redirect occuring that causes _IECreate to think that the page load is complete before it gets to the page you want to parse. For me, the redirect is to http://www.update.microsoft.com/microsoftu...t.aspx?ln=en-us -- probably best to go directly there or you'll need to do something like testing the URL (_IEPropertyGet - localtionurl) to see if it has changed and then do an _IELoadWait.

I can't test the rest of the script at the moment because I already have all updates installed.

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

Ok, i have changed the IECreate to IEAttach to not redirect but without success, because it does not find any frame, i dont know why?

#include <IE.au3>

#include <array.au3>

$sURL="http://update.microsoft.com/windowsupdate/v6/default.aspx?ln=es"

$oIE = _IEAttach($sURL, "url")

$oFrames = _IEFrameGetCollection ($oIE)

$iNumFrames = @extended

For $i = 0 to ($iNumFrames - 1)

$oFrame = _IEFrameGetCollection ($oIE, $i)

MsgBox(0, "Frame Info", _IEPropertyGet ($oFrame, "locationurl"))

$sText = _IEBodyReadText ($oFrame)

$aArray = _StringBetween($sText,"(KB",")")

If IsArray($aArray) Then

_ArraySort($aArray)

$iRetCode = _ArrayToClip( $aArray, 0 )

FileOpen("Test.txt", 2)

FileWrite("Test.txt", ClipGet())

Else

MsgBox(0, 'Empty', 'Nothing found')

EndIf

Next

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