|
-
Jul 17th, 2006, 12:46 PM
#1
Thread Starter
Junior Member
[RESOLVED] Parsing Source Code in a Textbox
Hey guys.
I've been at work on an Image auto-uploader for the past day or so. I've got everything working except this.
When it loads the upload page, I need the link to the direct image to be displayed. I've tried sending the source to a textbox and going from there.. but no luck.
Heres the html of a sample results page:
HTML Code:
<table width="760" cellspacing="0" cellpadding="5" border="0" class="table_decoration" align="center"><tr><td><p><a href="http://imageshack.us"><b>Upload</b></a> another image. <a href="http://reg.imageshack.us/register.php" target="_blank"><b>Register</b></a> for free. <a href="http://img124.imageshack.us/done.php?l=img124/804/1hz5.jpg"><b>Link</b></a> to this page. Please don't change any codes while linking!</p><br /><p>Please use clickable thumbnail codes (they save ImageShack's bandwidth):</p><input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="<a href="http://img124.imageshack.us/my.php?image=1hz5.jpg" target="_blank"><img src="http://img124.imageshack.us/img124/804/1hz5.th.jpg" border="0" alt="Free Image Hosting at www.ImageShack.us" /></a>" /> Thumbnail for Websites <br /><input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="[URL=http://img124.imageshack.us/my.php?image=1hz5.jpg][IMG]http://img124.imageshack.us/img124/804/1hz5.th.jpg[/IMG][/URL]" /> Thumbnail for forums (1)<br />
<input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="[url=http://img124.imageshack.us/my.php?image=1hz5.jpg][img=http://img124.imageshack.us/img124/804/1hz5.th.jpg][/url]" /> Thumbnail for forums (2)<br />
<input type="text" onClick='highlight(this);' style="width: 300px" size="70" value="Thanks to ImageShack for [URL=http://imageshack.us]Free Image Hosting[/URL]" /> Link back to ImageShack or use the <a href="http://reg.imageshack.us/content.php?page=linkto"><b>banners and buttons</b></a>.<br /><br /><table cellspacing="0" cellpadding="0" border="0"><tr><td valign="bottom"><!-- BEGIN STANDARD TAG - 300 x 250 - imageshack: Medium Rectangle - DO NOT MODIFY -->
<SCRIPT TYPE="text/javascript" SRC="http://content.yieldmanager.com/rmtag3.js"></SCRIPT>
<SCRIPT language="JavaScript">
var rm_host = "http://ad.yieldmanager.com";
var rm_section_id = 62324;
var rm_iframe_tags = 1;
rmShowAd("300x250");
</SCRIPT>
<!-- END TAG -->
</td><td width="20"> </td><td valign="top"><p><input type="button" value="QuickPost" onclick="window.location='http://blogpost.imageshack.us/blogpost/postblog.php?id=img124/804/1hz5.jpg'" /> this image to any blog (MySpace, LiveJournal, etc)!<br /><input type="button" value="Start a SlideShow" onclick="window.location='http://imageshack.us/slideshow/index.php?url=http://img124.imageshack.us/img124/804/1hz5.jpg&optsize=320x240&action=transload'" /> with this image.</p><table cellspacing="0" cellpadding="0" border="0"><tr><td><br /><a href="http://img124.imageshack.us/my.php?image=1hz5.jpg"><img src="http://img124.imageshack.us/img124/804/1hz5.th.jpg" border="0" /></a></td><td width="10"> </td><td><!-- FASTCLICK.COM 180x150 Rectangle CODE for imageshack.us -->
<script language="javascript" src="http://media.fastclick.net/w/get.media?sid=20143&m=7&tp=9&d=j&t=n"></script>
<noscript><a href="http://media.fastclick.net/w/click.here?sid=20143&m=7&c=1" target="_blank">
<img src="http://media.fastclick.net/w/get.media?sid=20143&m=7&tp=9&d=s&c=1"
width=180 height=150 border=1></a></noscript>
<!-- FASTCLICK.COM 180x150 Rectangle CODE for imageshack.us -->
</td></tr></table></td></tr></table><br /><input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="[URL=http://imageshack.us][IMG]http://img124.imageshack.us/img124/804/1hz5.jpg[/IMG][/URL]" /> Hotlink for forums (1)<br />
<input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="[url=http://imageshack.us][img=http://img124.imageshack.us/img124/804/1hz5.jpg][/url]" /> Hotlink for forums (2)<br /><input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="<a href="[url]http://imageshack.us"><img[/url] src="[url]http://img124.imageshack.us/img124/804/1hz5.jpg"[/url] border="0" alt="Image Hosted by ImageShack.us" /></a>" /> Hotlink for Websites <br /><input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="http://img124.imageshack.us/my.php?image=1hz5.jpg" /> <a href="http://img124.imageshack.us/my.php?image=1hz5.jpg"><b>Show</b></a> image to friends<br />
<input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="http://img124.imageshack.us/img124/804/1hz5.jpg" /> Direct link to image<br /><br /><!--AdRevolver code begin-->
<SCRIPT language="JavaScript">
The code that contains the URL I want displayed is here:
HTML Code:
<input type="text" onClick='highlight(this);' style="width: 500px" size="70" value="http://img124.imageshack.us/img124/804/1hz5.jpg" /> Direct link to image
The link will always be different. The only constant thing is the tags around the URL and the http://img.
Any ideas?
Last edited by Hack; Jul 18th, 2006 at 06:04 AM.
Reason: Added green "resolved" checkmark Last edited by JackDamian : Yesterday at 02:36 PM. Reason: Resolved.
-
Jul 17th, 2006, 12:52 PM
#2
Re: Parsing Source Code in a Textbox
what are you loading this in? webbrowser control?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jul 17th, 2006, 12:55 PM
#3
Thread Starter
Junior Member
Re: Parsing Source Code in a Textbox
Yeah. I had the source sent to a textbox, and was going to parse it from there.
-
Jul 17th, 2006, 12:56 PM
#4
Re: Parsing Source Code in a Textbox
[EDIT] you posted in between mine [/EDIT]
and I am assuming you want the link displayed in a textbox
Add a reference to the Microsoft HTML object library
VB Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Application) Then
Dim HTML As HTMLDocument
Dim HTML_IE As HTMLInputTextElement
Set HTML = WebBrowser1.Document
For Each HTML_IE In HTML.getElementsByTagName("input")
If Left(HTML_IE.Value, 10) = "http://img" Then
Text1 = HTML_IE.Value
Exit For
End If
Next
End If
End Sub
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jul 17th, 2006, 01:10 PM
#5
Thread Starter
Junior Member
Re: Parsing Source Code in a Textbox
Wow. That worked.. well, it half worked.
It came back with this link:
http://img193.imageshack.us/my.php?image=4vl1.jpg
Which is the link just above the one I need:
http://img193.imageshack.us/img193/3492/4vl1.jpg
I guess its possible to change the link around to make it fit? But is there any way to have it grab the second one? Maybe by making the searching a bit more specific?
-
Jul 17th, 2006, 01:18 PM
#6
Re: Parsing Source Code in a Textbox
sure.. well.. does the link above it always have my.php? in it?
if so:
VB Code:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
If (pDisp Is WebBrowser1.Application) Then
Dim HTML As HTMLDocument
Dim HTML_IE As HTMLInputTextElement
Set HTML = WebBrowser1.Document
For Each HTML_IE In HTML.getElementsByTagName("input")
If Left(HTML_IE.Value, 10) = "http://img" And [B]InStr(HTML_IE.Value, "my.php?")[/B] = 0 Then
Text1 = HTML_IE.Value
Exit For
End If
Next
End If
End Sub
Just mess with that iff statement to make sure you get the right one
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Jul 17th, 2006, 01:35 PM
#7
Thread Starter
Junior Member
Re: Parsing Source Code in a Textbox
That worked like a charm I was messing with that, but should have known to have it = 0. I appreciate your help alot.
-
Jul 17th, 2006, 01:56 PM
#8
Re: [RESOLVED] Parsing Source Code in a Textbox
no problem.
you can do LOTS with the help of the HTML object library 
check out my webbrowser control tutorial (Link in my sig)
have fun
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|