Autor Beitrag
chukalv
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: Mo 02.05.05 15:36 
Is it possible to load a web page only as text?
For example webbrowser loads not only the source, but also generates the page and downloads the images and active elements.
But I would like to get only the page as plain text, only it`s source...
Is that possible?

I was trying to use idHTTP.get('my.siyte.com'), but it always shows errors like:
"302 Moved temporarily"...
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Mo 02.05.05 16:01 
sure. try adding a 'http://' before. this works.

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
chukalv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: Mo 02.05.05 16:09 
It works not! It always gives out the error "302 Moved temporarily"

I`ve read a spanish site.. As much as I understood, the idhttp won`t load a page if there are temporar tags or something like that.

Maybe it`s connected with that I`m trying to download a page that is avalaible only after logging in...But the webbrowser get`s and shows the site correctly...
Are there no ways to load only the source with the help of the webbrowser?
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mo 02.05.05 16:13 
Hi!

Have a look at my Suche in: Delphi-Forum, Delphi-Library MINI WEBBROWSER DEMO
chukalv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: Mo 02.05.05 16:22 
I didn`t found that what I needed at your demo browser.
Does it do what I asked?
The simple webbrowser also shows the source code of the page, but I need the just source code (and not after the page is loaded)...
toms
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1099
Erhaltene Danke: 2



BeitragVerfasst: Mo 02.05.05 16:51 
user profile iconchukalv hat folgendes geschrieben:

but I need the just source code (and not after the page is loaded)...


Well, in this code TWebbrowser is not suitable.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 02.05.05 17:18 
also try changing the UserAgent variable in idHttp to something like 'Internet Explorer 5.0'

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Mo 02.05.05 17:28 
another simple way to download something from the web ( a html site or whatever )
is that code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
uses
  ... ,
  urlmon;

function DownloadFile(SourceFile, DestFile: string): Boolean;
begin
  try
    Result :=  UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0;
  except
    Result := False;
  end;
end;

_________________
es gibt leute, die sind genetisch nicht zum programmieren geschaffen.
in der regel haben diese leute die regel...
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mo 02.05.05 17:37 
There should be an entry in the http response header containing the correct URL (namely "Location:"). Modern Browsers automatically redirect you to this new URL but this is not done automatically when using a function that only receives the page without interpreting it.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Di 03.05.05 13:38 
try to set the property HandleRedirects to true.
This should fix your problem !

_________________
In the beginning was the word.
And the word was content-type: text/plain.
chukalv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: Di 10.05.05 16:50 
To:user profile iconretnyg - I found the UserAgent property. But how can I know to what to change it?
I`ve tried it to change to 'Mybrowser' and changed the Twebbrowser useragent to 'Mybrowser' but it didn`t worked....
To:user profile iconmatze - By setting HandleRedirects to true solves the problem that the idhttp redirects to another site and not alerts an error..

But. I need to get the source of the directing site.

As I said I`m logging in to a site with Twebbrowser. And I need to get the source code from that site after a while. As the site changes all the time, I need only it`s source.

HOW to do that?
chukalv Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 44



BeitragVerfasst: Di 10.05.05 17:38 
Okey... I found one dirty way how to do that...

Take the embeddedWB component and set the DLCTL_DOWNLOADONLY property on true.. So only the pages source will be downloaded... And then just on the browsers event OnDocumentComplete put where to place the source -
ausblenden Quelltext
1:
2:
 
xbrowser.SaveToStrings(memo1.lines);