| Author |
Topic Search Topic Options
|
Dazz
Newbie
Joined: 24 January 2003
Location: United Kingdom
Status: Offline
Points: 29
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
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">
|
 |
Dazz
Newbie
Joined: 24 January 2003
Location: United Kingdom
Status: Offline
Points: 29
|
Post Options
Thanks(0)
Quote Reply
Posted: 16 February 2003 at 1:57pm |
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?
|
 |
peterm
Newbie
Joined: 24 November 2002
Location: United Kingdom
Status: Offline
Points: 27
|
Post Options
Thanks(0)
Quote Reply
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)
|
 |
Mart
Senior Member
Joined: 30 November 2002
Status: Offline
Points: 2304
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
Dazz
Newbie
Joined: 24 January 2003
Location: United Kingdom
Status: Offline
Points: 29
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
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
|
 |
MorningZ
Senior Member
Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
|
Post Options
Thanks(0)
Quote Reply
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
|
 |