Solved

indy 9 and delphi 7 how do you idenifty the url for the redirect page so i can grab the text on the redirected web page

Posted on 2003-11-19
9
746 Views
Last Modified: 2012-05-07
can anyone help me with some example code giving me the ability to grab text from the redirected page

for example:
 I use the following where s is defined as a string to grab a web page

   s := IdHTTP1.Get(' http://www.microsoft.com/tt');




if I go to an imagininary micorosft page that does not exist such as http://www.microsoft.com/tt -it redirects to a page not found web page, I can catch the response code from the server using idhttp1. ResponseCode idenifying the web page has been reidrected.


what I want to do is grab the text on that redirected page and if possilbe grab the url. All I know is the code will be in the onrediect event for idhttp1.



thanks in advance

Ian
0
Comment
Question by:alchemy9
  • 6
  • 3
9 Comments
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9787426
The URL is in the dest parameter of the OnRedirect.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9787441
From the Indy help file:

TIdHTTPOnRedirectEvent = procedure (Sender: TObject; var dest: string; var NumRedirect: Integer; var Handled: boolean; var VMethod: TIdHTTPMethod) of object;

Description

TIdHTTPOnRedirectEvent is a event type triggered when an HTTP client is notified of a redirection request from the HTTP server. TIdHTTPOnRedirectEvent is used in conjunction with an event handler to respond to the event.
Sender is the HTTP client that has received the redirection request.
***********************************************************
Dest is the new location or URL for the resource. Dest is often used to update a GUI application with the current URL.
***********************************************************

NumRedirects is a variable used to accumulate the number of redirection requests that the HTTP client has received.

Handled indicates that the event handler should respond to the redirection request. Set Handled to False if the application is unable to respond to the redirection
request.

0
 

Author Comment

by:alchemy9
ID: 9790107
ok im still none the wiser, tried this an still no joy is it possible you could give me some sample code to show a redirect from the following page


 s := IdHTTP1.Get(' http://www.microsoft.com/tt');  //where s is a string

can you show me in code how the redirect will work and how to collect the redirected page into  a string or listbox


thanks
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 26

Expert Comment

by:EddieShipman
ID: 9790689
Hate to say it but that page produces a 404, not found.
Microsoft's servers are configured to return the page you see.
I found no way to get the url's as the only response sent is the 404.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9790694
The OnRedirect never fires becuase it is not redirected but the server sends the error page
for the 404.
0
 

Author Comment

by:alchemy9
ID: 9791521
oops your right

but if you use www.micorsoft.com/test you get a 301 error

anyway so my next question is this:

microsoft redirect to another page and IE downloads this reidrected page, so how can this be implemeted with indy. Is it possible to have a redirect even with a 404 error page not found????

All rather confusing.



0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 9799587
Does the URL www.micorsoft.com/test actually do a redirect?
I see that it doesn't go to a Microsoft page.

It really depends on how the server is configured. If it is configured to
show a different 404 page, then that is handled by the server and a
redirect is not sent.
0
 

Author Comment

by:alchemy9
ID: 9800505
OK but how does IE display this page?

the server must send a message to IE to display the 404 error page..
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 250 total points
ID: 9800595
Yes, it sends it in the reponse stream. I don't know why Indy doesn't get it.
My suggestion at this pont would be to ask on the indy newsgroups.

news.atozedsoftware.com
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best Firemonkey component pack 1 119
Simple Delphi Question 9 96
QRReport  TQrmemo vertical stretching 1 53
how to resize animated Gif image in delphi ? 1 35
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question