Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Getting URL
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Getting URL

 Post Reply Post Reply Page  12>
Author
Dazz View Drop Down
Newbie
Newbie
Avatar

Joined: 24 January 2003
Location: United Kingdom
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dazz Quote  Post ReplyReply Direct Link To This Post Topic: Getting URL
    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"


' 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

%>



Edited by Dazz
Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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">
Back to Top
Dazz View Drop Down
Newbie
Newbie
Avatar

Joined: 24 January 2003
Location: United Kingdom
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dazz Quote  Post ReplyReply Direct Link To This Post 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?

Back to Top
peterm View Drop Down
Newbie
Newbie


Joined: 24 November 2002
Location: United Kingdom
Status: Offline
Points: 27
Post Options Post Options   Thanks (0) Thanks(0)   Quote peterm Quote  Post ReplyReply Direct Link To This Post 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)

Back to Top
Mart View Drop Down
Senior Member
Senior Member
Avatar

Joined: 30 November 2002
Status: Offline
Points: 2304
Post Options Post Options   Thanks (0) Thanks(0)   Quote Mart Quote  Post ReplyReply Direct Link To This Post 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

Back to Top
Dazz View Drop Down
Newbie
Newbie
Avatar

Joined: 24 January 2003
Location: United Kingdom
Status: Offline
Points: 29
Post Options Post Options   Thanks (0) Thanks(0)   Quote Dazz Quote  Post ReplyReply Direct Link To This Post 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 ?



Edited by Dazz
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post 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 %>" target="_blank"><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
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 17 February 2003 at 2:41pm
btw, if you wanna see that code in action, execute it here
Contribute to the working anarchy we fondly call the Internet
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.