Results 1 to 8 of 8

Thread: [RESOLVED] Parsing Source Code in a Textbox

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    19

    Resolved [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="&lt;a href=&quot;http://img124.imageshack.us/my.php?image=1hz5.jpg&quot; target=&quot;_blank&quot;&gt;&lt;img src=&quot;http://img124.imageshack.us/img124/804/1hz5.th.jpg&quot; border=&quot;0&quot; alt=&quot;Free Image Hosting at www.ImageShack.us&quot; /&gt;&lt;/a&gt;" /> 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">&nbsp;</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">&nbsp;</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="&lt;a href=&quot;[url]http://imageshack.us&quot;&gt;&lt;img[/url] src=&quot;[url]http://img124.imageshack.us/img124/804/1hz5.jpg&quot;[/url] border=&quot;0&quot; alt=&quot;Image Hosted by ImageShack.us&quot; /&gt;&lt;/a&gt;" /> 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.

  2. #2
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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"

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    19

    Re: Parsing Source Code in a Textbox

    Yeah. I had the source sent to a textbox, and was going to parse it from there.

  4. #4
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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:
    1. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.     If (pDisp Is WebBrowser1.Application) Then
    3.         Dim HTML As HTMLDocument
    4.         Dim HTML_IE As HTMLInputTextElement
    5.         Set HTML = WebBrowser1.Document
    6.         For Each HTML_IE In HTML.getElementsByTagName("input")
    7.             If Left(HTML_IE.Value, 10) = "http://img" Then
    8.                 Text1 = HTML_IE.Value
    9.                 Exit For
    10.             End If
    11.         Next
    12.     End If
    13. End Sub
    JPnyc rocks!! (Just ask him!)
    If u have your answer please go to the thread tools and click "Mark Thread Resolved"

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    19

    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?

  6. #6
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    Re: Parsing Source Code in a Textbox

    sure.. well.. does the link above it always have my.php? in it?

    if so:
    VB Code:
    1. Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    2.     If (pDisp Is WebBrowser1.Application) Then
    3.         Dim HTML As HTMLDocument
    4.         Dim HTML_IE As HTMLInputTextElement
    5.         Set HTML = WebBrowser1.Document
    6.         For Each HTML_IE In HTML.getElementsByTagName("input")
    7.             If Left(HTML_IE.Value, 10) = "http://img" And [B]InStr(HTML_IE.Value, "my.php?")[/B] = 0 Then
    8.                 Text1 = HTML_IE.Value
    9.                 Exit For
    10.             End If
    11.         Next
    12.     End If
    13. 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"

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jul 2006
    Posts
    19

    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.


  8. #8
    PowerPoster Static's Avatar
    Join Date
    Oct 2000
    Location
    Rochester, NY
    Posts
    9,390

    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
  •  



Click Here to Expand Forum to Full Width