Print Page | Close Window

Getting URL

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=190
Printed Date: 28 March 2026 at 9:10am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Getting URL
Posted By: Dazz
Subject: Getting URL
Date Posted: 15 February 2003 at 9:01am

Hi
Using the following script im trying to capture data on a page and show it on another website, it works fine however images do not display and i dont really want to have to upload them onto the server that this script runs off.
Has anyone got any ideas how i can make this script display images properly?

Any help would be greatly appreciated.

Regards Dazz

<%

' Intruduce the url you want to visit
GotothisURL = " http://www.server.co.uk/page.asp - http://www.server.co.uk/page.asp "


' Create the xml object
Set GetConnection = CreateObject("Microsoft.XMLHTTP")


' Conect to specified URL
GetConnection.Open "get", GotothisURL, False
on error resume next
GetConnection.Send


' ResponsePage is the response we will get when visiting GotothisURL
ResponsePage = GetConnection.responseText


' We will write
if ResponsePage="" then
Response.write("The page is not available")
else
Response.write(ResponsePage)
end if


Set GetConnection = Nothing

%>




Replies:
Posted By: Mart
Date Posted: 16 February 2003 at 11:42am
Instead of on the page you want to get writing <img src="whatever.gif"> change it to be <img src="http://yourserver.com/whatever.gif">


Posted By: Dazz
Date Posted: 16 February 2003 at 1:57pm

Originally posted by Mart Mart wrote:

Instead of on the page you want to get writing <img src="whatever.gif"> change it to be <img src="http://yourserver.com/whatever.gif">

The site im getting data from isnt one of mine so that isnt an option, are there any changes I can make to that code or a similar one so that the images will display correctly? Or is there a script that only lists all the links on a page and doesnt try to get images?



Posted By: peterm
Date Posted: 17 February 2003 at 10:53am

 

Run the following on the string that has the html (assuming strText is your string)

strText = Replace(strText, "<img src=""", "<img src=""http://www.originalserveraddress.com/location/""")

This will effectively put the full path for any images in the HTML source. (If the images are in different paths then it'll be more complicated)



Posted By: Mart
Date Posted: 17 February 2003 at 11:22am

Or to get rid of the images all together replace

Response.write(ResponsePage) that line with

response.write(Replace(ResponsePage, "img", "noscript"))

This will hide the image in the users browser



Posted By: Dazz
Date Posted: 17 February 2003 at 1:10pm

Is there a way to list all the links on a page without having to fetch the whole page or display the whole page ?



Posted By: MorningZ
Date Posted: 17 February 2003 at 1:55pm
you are going to have to fetch all the page's code, and parse through and grab the links..... for examxple:


<%@ Language=VBScript %>
<% Response.Expires = -1 %>
<% Response.Buffer = True %>
<%
PageLocation = "http://www.morningz.com/sections/"

Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open "GET", PageLocation, False
xml.Send
strHTML = xml.ResponseText
Set xml = Nothing
Dim objRegExp, objMatch, objMatches
Set objRegExp = New RegExp

objRegExp.IgnoreCase = True
objRegExp.Global = True
objRegExp.Pattern = "<a (.*?)</a>"
Set objMatches = objRegExp.Execute(strHTML)

%>
<html>
<body style="font-size: 10px; font-family: verdana;">
All Retrieved Links from <a href="<%= PageLocation %>"><b><%= PageLocation %></b></a><hr />
<br />
<font style="color: blue;">HTML Output:</font><br />
<%
For Each objMatch in objMatches
     Response.Write(objMatch & "<br />")
Next
%>
<br /><hr />
<font style="color: blue;">Text Output:</font><br />
<pre>
<%
For Each objMatch in objMatches
     Response.Write(Server.HTMLEncode(objMatch) & "<br />")
Next
%>
</pre>
<%
Set objMatch = Nothing
Set objRegExp = Nothing
%>
</body>
</html>



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: MorningZ
Date Posted: 17 February 2003 at 2:41pm
btw, if you wanna see that code in action, http://www.morningz.com/sections/playground/listlinks.asp - execute it here

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Dazz
Date Posted: 17 February 2003 at 3:43pm

How do i set a location for the images eg fix http://www.server.co.uk/folder - http://www.server.co.uk/folder on the front of each image location ?

Again your help is greatly appreciated



Posted By: MorningZ
Date Posted: 17 February 2003 at 3:46pm
can you tell me what the "real" URL is so i can see the format of the image tag(s)?

then i can tweak the above regular expression to match

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Dazz
Date Posted: 17 February 2003 at 4:07pm
The information that im wanting to extract is on this page
http://www.jenric.freeserve.co.uk/links.htm - http://www.jenric.freeserve.co.uk/links.htm
I want to either get the whole page and display the images or get all the links on the page and also display the image links.


Posted By: MorningZ
Date Posted: 17 February 2003 at 4:34pm
this will at least get you started, i dont have the time or desire to write the whole thing for you, but you should be able to take the following and tweak it to your needs..... if you need RegEx help, http://www.aspfaqs.com - ASPFaqs is an excellent resource....


<%@ Language=VBScript %>
<% Response.Expires = -1 %>
<% Response.Buffer = True %>
<%
PageDomain = "http://www.jenric.freeserve.co.uk/"
PageLocation = PageDomain & "links.htm"

Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
xml.Open "GET", PageLocation, False
xml.Send
strHTML = xml.ResponseText
Set xml = Nothing
Dim objRegExp, objMatch, objMatches
Set objRegExp = New RegExp

objRegExp.IgnoreCase = True
objRegExp.Global = True
%>
<html>
<body style="font-size: 10px; font-family: verdana;">
All Retrieved Images/Links/Both from <a href="<%= PageLocation %>"><b><%= PageLocation %></b></a><hr />
<br />
<font style="color: blue;">Just Images:</font><br />
<%
objRegExp.Pattern = "<img border=""0"" src=""graphics_new/(.*?)>"
Set objMatches = objRegExp.Execute(strHTML)
For Each objMatch in objMatches
     Response.Write( Replace(objMatch,"src=""grap", " align=""left"" src=""" & PageDomain & "grap") )
     Response.Write(Server.HTMLEncode(objMatch) & "<br clear=""all""/>")
Next
%>
<br /><hr />
<font style="color: blue;">All Links:</font><br />
<%
objRegExp.Pattern = "<a (.*?)</a>"
Set objMatches = objRegExp.Execute(strHTML)
For Each objMatch in objMatches
     Response.Write( Server.HTMLEncode(objMatch) & "<br clear=""all""/>")
Next
%>
<%
Set objMatch = Nothing
Set objRegExp = Nothing
%>
</body>
</html>


-------------
Contribute to the working anarchy we fondly call the Internet



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net