Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Ucitavanje u fajl

[es] :: Perl :: Ucitavanje u fajl

[ Pregleda: 1225 | Odgovora: 3 ]

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Dragoslav Krunić

Član broj: 225
Poruke: 1076
*.beograd-3.tehnicom.net



Profil

icon Ucitavanje u fajl13.04.2001. u 18:11

Da li neko moze da mi kaze kako da neku web stranicu (npr. pocetnu stranicu yahoo-a) uz pomoc perl-a ucitam u jedan fajl?
13.04.2001. u 18:11 

ventura
Danko Vuković
Beograd

Član broj: 32
Poruke: 4352
*.brick.net

ICQ: 10624010
Sajt: www.elbet.co.yu


Profil

icon Re: Ucitavanje u fajl13.04.2001. u 22:25
Uz pomoc modula LWP::UserAgent. imas info na search.cpan.org.




#!/usr/bin/perl

use LWP::UserAgent;

$ua = new LWP::UserAgent;
$ua->agent("Ventura browser");

$adresa = "http://www.yahoo.com/";

$req = new HTTP::Request 'GET' => $adresa;
$req->header('Accept' => 'text/html');


$res = $ua->request($req);


if ($res->is_success) {
$file = $res->content;
} else {
print "Error: " . $res->code . " " . $res->message;
}


print "$file\n";

[Ovu poruku je menjao ventura dana 04-13-2001 u 03:27 PM GMT]
13.04.2001. u 22:25 

Gojko Vujovic
Juniper Networks
Amsterdam, NL

Administrator
Član broj: 1
Poruke: 13031
*.gojko.ss.

Sajt: www.gojkovujovic.com


Profil

icon Re: Ucitavanje u fajl14.04.2001. u 01:24
Jos lakse, sa LWP::Simple :

Code:

#!/bin/perl
  use LWP::Simple;

  $url = 'http://www.yahoo.com';
  $localfile = 'test.txt';

  $document = get($url) or do
  { 
    print "Nista od get-a.." ;
    exit (0) ; 
  } ;

  @document = split /\n/, $document;

  open(LOCALFILE,">$localfile") || die;
  flock(LOCALFILE,2);
  print $line;
  foreach $line (@document)
  {
    print LOCALFILE "$line\n";
  } 
  flock(LOCALFILE,8);
  close(LOCALFILE);

14.04.2001. u 01:24 

Dragoslav Krunić

Član broj: 225
Poruke: 1076
*.beograd-3.tehnicom.net



Profil

icon Re: Ucitavanje u fajl14.04.2001. u 09:53
Hvala!
14.04.2001. u 09:53 

[es] :: Perl :: Ucitavanje u fajl

[ Pregleda: 1225 | Odgovora: 3 ]

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.