Jump to content

Trying to Get info From A Link...But I Can't...?


Recommended Posts

I am trying to get the URL from the download link at keepvid.com, but I can't seem to grab it.

What I'm doing right now is browsing to www.keepvid.com and putting in a YouTube URL and clicking the Submit button. All I want is the URL behind the "Download Link" link. The URL seems to be coming from a "_blank" page on the same page, but I can't put it in a variable for the life of me.

Maybe someone can shed some light for me. Here's my code, so far.

#include <IE.au3>
$oIE = _IECreate ("www.keepvid.com")
$oForm = _IEFormGetCollection ($oIE, 0)
$oText = _IEFormElementGetCollection ($oForm, 0)
$oSubmit = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oText, "http://www.youtube.com/watch?v=Ljd0IKSGAKg");just a sample YouTube link
_IEAction ($oSubmit, "click")

Thanks

Link to comment
Share on other sites

the link in question resides in an iFrame.

#include <IE.au3>
$oIE = _IECreate ("www.keepvid.com")
$oForm = _IEFormGetCollection ($oIE, 0)
$oText = _IEFormElementGetCollection ($oForm, 0)
_IEFormElementSetValue ($oText, "http://www.youtube.com/watch?v=Ljd0IKSGAKg");just a sample YouTube link
_IEFormSubmit($oForm)

_IELoadWait($oIE)

$oForm2 = _IEFormGetCollection ($oIE, 1)
_IELinkClickByText($oForm2, "Download Link")

_IELoadWait($oIE)

that should probably work (not tested)

[font="Impact"] I always thought dogs laid eggs, and I learned something today. [/font]
Link to comment
Share on other sites

Thanks for the suggestion. I gave it a shot and Scite came up with this:

--> IE.au3 Warning from function _IEFormGetCollection, $_IEStatus_NoMatch--> IE.au3 Error from function _IELinkClickByText, $_IEStatus_InvalidDataType

The Download Link "link" is not even an actual link according to the source...that's the funny part...I'm stumped...

Link to comment
Share on other sites

  • Moderators

This would work if it weren't for cross site scripting.

#include <IE.au3>

$sURL = "www.keepvid.com"
$sLink = "http://www.youtube.com/watch?v=Ljd0IKSGAKg"

_IEErrorHandlerRegister()

$oIE = _IECreate($sURL)
$oForm = _IEFormGetObjByName($oIE, "chooser_form_2")
$oURL = _IEFormElementGetObjByName($oForm, "url")
$oSubmit = _IEFormElementGetCollection($oForm, 2)
_IEFormElementSetValue($oURL, $sLink)
_IEAction($oSubmit, "click")

$oFrame = _IEFrameGetObjByName($oIE, "keepWindow")
_IELoadWait($oFrame)
$oLink = _IELinkGetCollection($oFrame, 1)
ConsoleWrite($oLink.href & @CR)

The only way I know of to get the link would be to manually "POST" the data.

Here is what Live HTTP Headers returns.

http://megaupload.net/keepvid.php

POST /keepvid.php HTTP/1.1
Host: megaupload.net
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3
Accept: application/x-shockwave-flash,text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://keepvid.com/
Content-Type: application/x-www-form-urlencoded
Content-Length: 66
url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DLjd0IKSGAKg&site=aa
HTTP/1.x 200 OK
Date: Mon, 07 May 2007 05:36:33 GMT
Server: Apache/2.0.52 (CentOS)
X-Powered-By: PHP/4.3.9
Content-Length: 629
Connection: close
Content-Type: text/html
Link to comment
Share on other sites

I'm puzzled by this and I'm not certain how or if you can work around it.

There is an iFrame involved and there is a cross site scripting access denied error.

The parent can write to the frame, but we Can't read from it.

#include <IE.au3>
$oIE = _IECreate ("keepvid.com", 1)

$oForm = _IEFormGetCollection ($oIE, 0)
$oText = _IEFormElementGetCollection ($oForm, 0)
$oSubmit = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oText, "http://www.youtube.com/watch?v=Ljd0IKSGAKg");just a sample YouTube link
_IEAction ($oSubmit, "click")

_IEErrorHandlerRegister()
$oFrame = _IEFrameGetObjByName($oIE,"keepWindow")
ConsoleWrite(_IEDocReadHTML($oFrame) & @CR)

Exit

--> COM Error Encountered in tmp-asdf99asdfkk.au3
----> $IEComErrorScriptline = 2165
----> $IEComErrorNumberHex = 80020009
----> $IEComErrorNumber = -2147352567
----> $IEComErrorWinDescription = Access is denied.
----> $IEComErrorDescription = Access is denied.
----> $IEComErrorSource = 
----> $IEComErrorHelpFile = C:\WINDOWS\system32\mshtml.hlp
----> $IEComErrorHelpContext = 0
----> $IEComErrorLastDllError = 0

No answers right now...

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

Link to comment
Share on other sites

Well, could there be a possible alternate solution for this?

My goal is to get the URL for a YouTube video (video-only, no controls) to stream as an flv file. I would then open the stream using Media Player Classic - which works great this way using keepvid and when done by hand.

Trying to think outside the box here :)

Edited by buymeapc
Link to comment
Share on other sites

Before doing the submit you could change the Form action -- $oForm.target = ""

Then the result will replace the current top-level document.

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

Very cool. Thanks Dale for that last tidbit, that did the trick.

Here's my code that worked.

#include <IE.au3>
#include <String.au3>
$oIE = _IECreate ("www.keepvid.com")
$oForm = _IEFormGetCollection ($oIE, 0)
$oText = _IEFormElementGetCollection ($oForm, 0)
$oSubmit = _IEFormElementGetCollection ($oForm, 2)
_IEFormElementSetValue ($oText, "http://www.youtube.com/watch?v=Ljd0IKSGAKg");just a sample YouTube link
$oForm.target = ""
_IEAction ($oSubmit, "click")

_IELoadWait($oIE)

$body = _IEBodyReadHTML($oIE)
$stream = _StringBetween($body, '<a href="', '">')
MsgBox(0, "", $stream[1])

Thanks all! :)

Link to comment
Share on other sites

Cool -- outside the box (frame)

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

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