...

View Full Version : Getting Links from an external page?



phill_ridout
03-14-2007, 05:21 PM
http://www.codingforums.com/showthread.php?p=544525#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.:thumbsup:

miranda
03-14-2007, 09:11 PM
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


<%
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
%>

SSJ
03-15-2007, 12:35 PM
I have read your both the threads.
You can do this by javascript.

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

degsy
04-18-2007, 03:52 PM
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&q=asp+remote+url&meta=

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum