Heeft er iemand enig idee of er ook sites bestaan waar je het weer vandaan kunt downloaden en op je eigen site zetten zonder hiervoor te werken met lelijke (i)frames of iets dergelijks.
Het gaat mij om het weer van Alanya en van de Bilt.
Hans
Likes: 0
Heeft er iemand enig idee of er ook sites bestaan waar je het weer vandaan kunt downloaden en op je eigen site zetten zonder hiervoor te werken met lelijke (i)frames of iets dergelijks.
Het gaat mij om het weer van Alanya en van de Bilt.
Hans
Daar kun je heel makkelijk onderstaand script voor gebruiken.
Code:#!/usr/bin/perl ############################################################################# # # To use the SSI call the script by placing the following HTML on your # webpage <!--#exec cgi="/cgi-bin/pageripper.cgi"--> # Be sure to CHMOD script to 755 for script to work # # # MAKE SURE THE PERL PATH ABOVE IS CORRECT OR IT WON'T WORK # MUST HAVE LWP:USERAGENT INSTALLED # ############################################################################# require LWP::UserAgent; # read command prompt read(STDIN, $commandprompt, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @theactualdata = split(/&/, $commandprompt); $newcommandprompt = ''; foreach $actualdata (@theactualdata) { ($name, $value) = split(/=/, $actualdata); if ($name ne 'page') { $newcommandprompt = $newcommandprompt . $actualdata } ; # change all the + to blank spaces $name =~ tr/+/ /; $value =~ tr/+/ /; # convert %20 to ' ' (a blank space), HEX - character conversion $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # convert < > to '' (NULL) $value =~ s/<([^>]|\n)*>//g; # eliminate the less than and greater than signs $value =~ s/<//g; $value =~ s/>//g; $URL{$name} = $value; } print "Content-type: text/html\n\n"; # store my url $url = $URL{'url'}; #=============================================================================== # #### VARIABLES THAT MUST BE CHANGED FOR SCRIPT TO WORK #### #=============================================================================== # 1 - MUST CHANGE - Change The URL below to the page you wish to begin extracting from $url = 'http://www.google.nl'; # 2 - Starting Point to extract from (must be exactly the way it is on the page) $start = '<SCRIPT>'; # 3 - Ending HTML $finish = '</BODY></HTML>'; # 4 - If links don't work change the HTML below to reflect the link source (remove the #'s) $sourcelink = '<a href="/h'; $newlink = '<a href="http://dailynews.yahoo.com/h'; # 5 - If images don't work change the html below to reflect the image source (remove the #'s) # $sourceimage = 'img src=\"'; # $newimage = 'img src=\"http://www.pollstar.com/news'; #=============================================================================== # DO NOT CHANGE ANYTHING BELOW THIS LINE. SCRIPT WILL NOT WORK. #=============================================================================== $start =~ s/ /\\s\+/; $start =~ s/\//\\\//; $finish =~s/ /\\s\+/; $finish =~ s/\//\\\//; # initialise the mem vars $t = ''; $content = ''; $contenttype = ''; $body = ''; $head = ''; $title = ''; $keywords = ''; $description = ''; $error = 0 ; $htmlcode = 0 ; # assign the browser agent $agent ='Mozilla/9.0 (Windows 98;US) Opera 4.00 [en]'; # print the HTML header print "<HTML><HEAD></HEAD><BODY>"; # has the user defined the URL if (!$url) { print "Enter the URL\n"; } else { # EXTRACT the page &getpage($url); # if error grabbing the page then print the return CODE RFC 2068. # HTTP 1.1 Protocol if ($error) { print "Error Getting Page : $url Code : $htmlcode<br>"; } # ERROR or NO ERROR print whatever is grabbed. $t = $content; # convert newline or return to blank spaces globally $t =~ s/\r/\n/gi; $t =~ s/\n/ /gi; # convert multiple blanks to a single blank globally $t =~ s/ / /gi; # convert tab to single blank globally $t =~ s/\t/ /gi; # get the meta tags, keywords, title, and descriptions &gettags($t); # print the return results print "$stuff"; # print "<tr><td bgcolor=\"#DDDDDD\">Body</td><td bgcolor=\"#CCCCCC\">$body</td></tr></table>"; } # end HTML # Must remain for script to work print "<br></a>"; print "<div align='right'>"; print " <table border='0' cellpadding='0' cellspacing='0' width='100%'>"; print " <tr>"; print " <td width='100%' align='right'><font size='1'> "; print " </a></font></td>"; print " </tr>"; print " </table>"; print "</body></html>"; # GET THE META TAGS sub gettags { my $mmyurl = shift; # store the content to $body variable $stuff = $mmyurl; #----------------begin here # get the page... $stuff = ($stuff =~s/$start(.+)$finish/ /i) ? $1 : 'No Title'; $stuff =~ s/$sourcelink/$newlink/ig; $stuff =~ s/$newlink$newlink/$newlink/ig; $stuff =~ s/$sourceimage/$newimage/ig; #----------------end here #========================================================================= # DO NOT CHANGE ANYTHING BELOW. SCRIPT WILL NOT WORK #========================================================================= } # GET THE PAGE sub getpage { my $myurl = shift; # $myurl stores the URL # define the user agent my $ua = new LWP::UserAgent; # $cookies =""; # define the timeout $ua->timeout(60); # set the browser agent $ua->agent($agent); # GET THE PAGE my $req = HTTP::Request->new(GET => $myurl); my $res = $ua->request($req); # get the content of the page and the content type $content = $res->content; $contenttype = $res->content_type; # if 200 success, then no error. if ($res->is_success) { $error =0; } # get the HTML error code RFC 2068 and store in HTMLCODE var. # dont forget to set the error flag. else { $htmlcode = $res->code(); $error =1; } }
Of via PHP:
Het is overigens wel verstandig om zoiets in een cronjob te stoppen zodat het laden van jouw pagina geen 10 seconden duurt wanneer de site waar je de gegevens vandaan haalt plat ligt.Code:<?php $responsepage = file_get_contents('http://www.nieuws.nl/weerverkeer'); if ($responsepage !== false) { // do something with the content } else { // an error happened } ?>
De gegevens van het KNMI zijn volgens mij ook gratis (en legaal) beschikbaar.
Ok maar met het perl script kun je heel precies de dynamische content selecteren die gewenst is en dus zo de content binnen je eigen vormgeving laden. Kan erg handig zijn.![]()
http://www.weathernews.nl/freedata/mdnoord.gif
die heb ik gewoon als img src, ideaal :]
http://www.weather.com bied de mogelijkheid om via hun XML-API het weer op je website te plaatsen.
Realhosting - proffesionele hosting, personal service
He bedankt voor de informatie
![]()
Park The Hosting Manager - your friend in hosting software
Hier een legio mogelijkheden:
http://gratisweerdata.buienradar.nl/
Edit: In geval van geen iframe kan je ook de desbetreffende url includen via php.
Laatst gewijzigd door bluebird; 02/02/07 om 22:22. Reden: Extra toevoeging.