Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Posts
    187
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Getting Links from an external page?

    http://www.codingforums.com/showthre...525#post544525

    My main question is can i read the HTML source from one page in to a varible? If any one has any ideas on how to produce similar asp code to that featured on the link would be great. Any Help Much Appreciated.

  • #2
    Senior Coder
    Join Date
    Dec 2002
    Location
    Arlington, Texas USA
    Posts
    1,072
    Thanks
    4
    Thanked 8 Times in 8 Posts
    You could do a screen scrape and get the data using the XMLHTTP object. This would put all of the html into a variable. You will now have to manipulate that variable to get the exact data that you are looking for

    Something like this
    Code:
    <%
    Dim xml
    Dim page
    Dim LinkStart
    Dim LinkEnd
    Dim hyperLink
    Dim intCurrent 
    Dim intUsed 
    ' Create an xmlhttp object:
    Set xml = Server.CreateObject("Microsoft.XMLHTTP")
    ' Opens the connection to the server.
    xml.Open "GET", "http://www.somewebsite.com/", False			
    ' Actually Sends the request and returns the data:
    xml.Send
    'fills the variable
    page = xml.responseText
    Set xml = Nothing   'removes the object from server memory
    'now all this is left is to parse the variable to get the links out of it
    LinkStart = "<a "
    LinkEnd = "</a>"
    
    Do until y = true
    	If InStr(1,page,LinkStart) <> 0 Then  'ensure there is a link to grab from the page
    		intCurrent = Len(page) 
    		intUsed = InStr(1,page,LinkEnd)+4
    		If (InStr(1,page,LinkStart)) < intUsed Then
    			hyperLink = mid(page, InStr(1,page,LinkStart), intUsed - InStr(1,page,LinkStart)) & "<br>"	 
    			page = Right(page, (intCurrent-intUsed)) 
    		Else 'just in case someone has placed an inadvertant </a> in the page
    			page = Right(page, (intCurrent-intUsed))	
    		End If
    		Response.Write hyperLink & "<br>" & vbCrLF	
    	Else
    		y = true
    	End If
    Loop
    %>

  • #3
    SSJ
    SSJ is offline
    Regular Coder
    Join Date
    Mar 2007
    Posts
    230
    Thanks
    0
    Thanked 4 Times in 4 Posts
    I have read your both the threads.
    You can do this by javascript.

    Visit this:
    This software helps you..
    http://iconico.com/DataExtractor/

  • #4
    Senior Coder
    Join Date
    Nov 2002
    Location
    North-East, UK
    Posts
    1,265
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can do this by javascript.
    javascript cannot access external domains.

    Visit this:
    This software helps you..
    http://iconico.com/DataExtractor/
    That is nothing to do with ASP


    With ASP, to grab the page you need xmlHTTP as mentioned above.
    http://www.google.co.uk/search?hl=en...mote+url&meta=

    To extract HTML you can use Regular Expressions
    http://www.4guysfromrolla.com/webtech/120400-1.2.shtml


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •