Autor Beitrag
lemming
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Mo 08.09.03 11:40 
Hi!

Ich habe hier folgenden Code. Damit will ich Deep Links machen so wie Google News. Ich mach halt Deep Links mit Google News ;).

Oder besser gesagt, ich hol für meine Seite die News von Google. Leider geht das irgendwie ned. Wenn ich news.google.de als Link nehmen funktinierts. Aber will ich ein Suchergebniss haben gehts wiederum ned.

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
use LWP::Simple;

&newsrequest;

sub newsrequest
{
  print "Content-type: text/html", "\n\n";

  my $page = get('http://news.google.de/news?q=eminem&hl=de&lr=&ie=UTF-8&edition=de&scoring=d') || die 'Can\'t get page'; 
  
  print "$page";
  print "+DONE";
  exit();
}



Bitte keine Diskussion ala "Ey, das darfsch du ned!". Wenn's Google darf, dann darf ichs auch. Basta.

Danke!
neojones
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1206
Erhaltene Danke: 1



BeitragVerfasst: Mo 08.09.03 13:12 
Ich glaube, Google blockt ab, wenn der Request-Header nicht stimmt.

Musst also noch einen Referrer und Referrer-URL angeben, dann könnte es oassen.

Viele Grüße,

Matthias

_________________
Ha! Es compiliert! Wir können ausliefern!
lemming Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 470

Mac OS 10.3.1
Delphi 6 Pro, Kylix 3
BeitragVerfasst: Mi 10.09.03 07:19 
Ja hast recht. So gehts:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
use LWP::UserAgent;
my $ua = LWP::UserAgent->new();
$ua->agent("Koqueror");

my $request = HTTP::Request -> new('GET',"http://news.google.de/news?q=eminem&hl=de&lr=&ie=UTF-8&edition=de&scoring=d");
my $response = $ua ->request($request);

if ($response -> is_success)
{        
  $google = $response->as_string ;        
  print "Content-Type: text/html\n\n";        
  print  $google;
}
else
{        
  print "Content-Type: text/html\n\n";        
  print $response->error_as_HTML();
}