Tux L i n u x * G u i d e

v o n * I n g o * B l e c h s c h m i d t * ( c ) * 2 0 0 1
Tux
|Home|

|Neue Artikel|

|Index|

|Liste|

|Code-Snippets|

|Links|

|Allgemeines|

|Cool Stuff|
Zeitungsarchiv
Fre Nov 30 14:39:16 MET 2001
Zeitung Zeitzeuge HTML wget Die-Welt DIE-WELT News

Dieser Artikel stellt ein Skript vor, welches - automatisch - das Online-Reservoir DER-WELT herunterlädt, konvertiert, und automatisch komprimiert.

LinuxGuide Druckbare Version
Man-Page
Sourcecode



      .~.   
      /V\   
     // \\  
    /(   )\ 
     ^`~'^  
     


Hosted at Sorceforge.net
No ePATENTS
Viewable With Any Browser
Burn All GIFs!

R
echtlicher Hinweis: Ich habe erhlich gesagt keine Ahnung, ob das gegen irgendwelche Copyrights verstößt. Sollte dieser Fall eintreten, bitte ich Sie, mich zu benachrichtigen.

Hier ist der notwendige Eintrag in der crontab...
# crontab
 
*/20 * * * * /pfad/DIE-WELT/get.sh
 
 

.. und hier ist das Skript, Download (Pfadangaben wenn nötig anpassen!):
# get.sh
 
#!/bin/bash
# get.sh - Gets the online reservoire from the German-speaking newspaper
#          DIE-WELT (THE-WORLD).
# Copyright (C) Fre Nov 30 14:55:40 MET 2001 - now by Ingo Blechschmidt
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# Ingo Blechschmidt
# Arberstraße 5
# 86179 Augsburg
# E-Mail: iblech@web.de, http://www.way.to/uselinux/
# Tel.: +49 / 821 882955
#
# 
#!/bin/bash

USERNAME=iblech				# Unbedingt anpassen!
PFAD=/home/iblech/spieletest/DIE-WELT	# siehe ^^^
					#        |

PATH=/home/$USERNAME/bin:/usr/local/bin:/usr/bin:/bin

[ -e $PFAD/l ] || > $PFAD/l

if [ ! "`cat $PFAD/l`" = "`date +%d`" ]; then

###############################################

/usr/sbin/isdnctrl dial ippp0

sleep 2

cd $PFAD

rm inhalt.htx
wget http://www.die-welt.de/inhalt.htx


HEUTE=` date +%Y/%m/%d `
mkdir -p $HEUTE

cat inhalt.htx | sed -e 's/>/>~/g' | tr '~' '\n' | egrep -e '/daten/[0-9][0-9][0-9][0-9]/[0-9][0-9]/[0-9][0-9]/' | grep 'std' | grep 'id="bold"' | sort -nr | uniq > $HEUTE/liste.txt

cat $HEUTE/liste.txt | gawk '{ print "http://www.die-welt.de/" substr($0, 33); }' | gawk '{ print substr($0, 1, length($0) - 2) "?print=1" }' > $HEUTE/liste2.txt

cd $HEUTE

wget -i liste2.txt -nd

/usr/sbin/isdnctrl hangup ippp0

a=0; b=0;
for i in *1; do
  b="artikel1"
  mv $i $b.x
  w3m -T text/html -dump $b.x > $b
  rm $b.x
done

###############################################
  
  date +%d > $PFAD/l
  
fi

 
 

Das Skript prüft dann zuerst, ob es heute schoneinmal aufgerufen wurde. Wenn nein, dann holt es zuerst die Titelseite. Es filtert die A-HREFs zu den Artikeln heraus und speichert sie in $PFAD/$HEUTE$liste.txt. Dann filtert es aus dieser Liste die URLs heraus, und übergibt sie wget. Dies lädt dann alle Beitrage herunter. In einem letzten Schritt wandelt get.sh die HTML-Beiträge in Text um und gibt ihnen einen anderen Namen.

Und was ist mit dem Komprimieren, wie in der Zusammenfassung versprochen? Nun, dies muss das Skript nicht erledigen. Das macht wieder einmal unser fleißiger Daemon cron:
# crontab, die Zweite
 
30 * 1 * * tar --append --verbose --verbose --file /pad/zum/tar-archiv.tar.bz2 --bzip2 /pfad/zur/welt/`date +%Y/%m/%d`
 
 

Viel Spaß mit DER-WELT!

Document Informations: Content-Type: text/html; charset=iso-8859-1
Author: Ingo Blechschmidt
Description: LinuxGuide - Dieser Artikel stellt ein Skript vor, welches - automatisch - das Online-Reservoir DER-WELT herunterlädt, konvertiert, und automatisch komprimiert.
Keywords: Zeitung, Zeitzeuge, HTML, wget, Die-Welt, DIE-WELT, News, LinuxGuide
Robots: all
Copyright: Copyright (C) 2002 by Ingo Blechschmidt
Date: 2003-11-30T14:39:16+02:00

Stichwortverzeichnis | Neue Artikel | Übersicht | Codesnippets | Links | Copyright | Cool Stuff | Home | Druckbare Version | Manpage | Sourcecode |
Diesen Artikel kritisieren, kommentieren oder ergänzen
Einen Neuen Artikel schreiben

 
This website is distributed under the GNU Free Documentation License .