Sign in to follow this  
Followers 0
Acvoin

Get a link with no id nor class

7 posts in this topic

How do i get the HREF property value from the code below:

...code with lots of links...
<p id="paragraph">
  <a href="http://somesite.com" target="_blank">Link to a site</a>
</p>
...code with lots of links...

Share this post


Link to post
Share on other sites



If it wasn't for that ID, I wouldn't post the P tag here :)

The questionis how do I use it?

Share this post


Link to post
Share on other sites

I don`t have to much idea, but did you try somethign like this

$Your_URL = "put your URL here"

$oIE = _IECreate($Your_URL)

$Obj = _IEGetObjectById(_$oIE, "paragraph")

If is Obj($Obj) then consolewrite($Obj.type&@CRLF)

Share this post


Link to post
Share on other sites

$oP = _IEGetObjById($oIE, "paragraph")
$oA = _IETagnameGetCollection($oP, "a", 0) ; scope to what's inside the P, get first A
ConsoleWrite($oA.href &@CRLF)

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

$sLink = StringRegExpReplace($sPageSource, "(?is).+<p\s*id=.paragraph.>\s*.+?f=\x22(\S+?)\x22\s.+", "$1")


George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Share this post


Link to post
Share on other sites

DaleHohm, thanks a lot, your method works just fine.

GEOSoft, way too hardcore :) But thanks.

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