deletemepleasekthanks Posted April 25, 2011 Share Posted April 25, 2011 Hi all, I found AutoIt and made a few test programs, however I'm stuck on my current project. I need to get the contents of an input box on a web page using IE. Using a website called ServImg (Image hosting), after uploading an image, you are presented with a page with a series of input boxs with links to the image in: I would like to get the contents of the bottom link (the direct one). I have tried many different ways but I cannot get any to work. This is the HTML source for the form (I cut out the other links to reduce space): <form name="formlinks"><div class="image_detail"><center><a href="image_preview.php?i=140&u=13052777" target="_blank" class="menu02"> ... <hr/><p class="txtsmall">Image url :</p><input type="text" name="direct_link140" value="http://i25.servimg.com/u/f25/13/05/27/77/wzlogo10.jpg" class="links" readonly="1" onclick="javascript:this.form.direct_link140.focus();this.form.direct_link140.select();" size="85" style="width:100%;" /> The thing that makes things slightly more difficult is that the name of the input box (in this case I mean "direct_link140" changes depending on the image index (I think, although it definately changes). Any help would be very much appriciated. Thanks in advance Wibble199 Link to comment Share on other sites More sharing options...
sahsanu Posted April 26, 2011 Share Posted April 26, 2011 (edited) The thing that makes things slightly more difficult is that the name of the input box (in this case I mean "direct_link140" changes depending on the image index (I think, although it definately changes). Take a look to below code. I know it is not a good regexp pattern but I'm tired (going bed in 5 minutes). I've used the below regex assuming "direct" will appear on every direct link. I mean, it will works on "direct_link140" on "directxxxxxxxx" and so on. If it doesn't work post a complete source code or try to find a pattern. $sSource = '"<form name="formlinks"><div class="image_detail"><center><a href="image_preview.php?i=140&' & _ 'u=13052777" target="_blank" class="menu02"><hr/><p class="txtsmall">Image url :</p><input t' & _ 'ype="text" name="direct_link140" value="http://i25.servimg.com/u/f25/13/05/27/77/wzlogo10.j' & _ 'pg" class="links" readonly="1" onclick="javascript:this.form.direct_link140.focus();this.fo' & _ 'rm.direct_link140.select();" size="85" style="width:100%;" />' $result = StringRegExp($sSource,'name="direct.*value="(.+?)"',1) If IsArray($result) Then MsgBox(0,"","Direct link is " & $result[0]) Else MsgBox(0,"","I didn't find the direct Link") EndIf Edited April 26, 2011 by sahsanu Link to comment Share on other sites More sharing options...
deletemepleasekthanks Posted April 26, 2011 Author Share Posted April 26, 2011 (edited) Great, I got it to work. Thank you sahsanu! Edited April 26, 2011 by Wibble199 Link to comment Share on other sites More sharing options...
deletemepleasekthanks Posted April 26, 2011 Author Share Posted April 26, 2011 Actually, I must have one something wrong =\$sSource = _IEBodyReadHTML($openedIE) ConsoleWrite($sSource) $result = StringRegExp($sSource,'name="direct.*value="(.+?)"',1) If IsArray($result) Then $imageLink = $result[0] Else MsgBox(0,"Crash","The link parsing has failed.") Exit EndIf GUISetState(@SW_HIDE) WinGetHandle("[ACTIVE]") Sleep(1000) Send("[img]"&$imageLink&"[/img]")This is the HTML source: http://pastebin.com/vBbYrhBsFor some reason it seems to be sending Host it Which is actually the text of a button, whereas I want the URL for the image in:<p class="txtsmall">Image url :</p><input style="width: 100%;" class="links" onclick="javascript:this.form.direct_link161.focus();this.form.direct_link161.select();" name="direct_link161" readOnly="1" value="http://i25.servimg.com/u/f25/13/05/27/77/horten11.jpg" size="85" type="text">Have I done something wrong with the script?The strange thing is though, the example you game me with the other link works fine ThanksWibble199 Link to comment Share on other sites More sharing options...
sahsanu Posted April 26, 2011 Share Posted April 26, 2011 Actually, I must have one something wrong =\ Change this: $result = StringRegExp($sSource,'name="direct.*value="(.+?)"',1) To this... and try again: $result = StringRegExp($sSource,'name="direct.*value=\s?"(http.*?)"',1) Link to comment Share on other sites More sharing options...
deletemepleasekthanks Posted April 26, 2011 Author Share Posted April 26, 2011 Thanks a lot sahsanu! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now