... | ... |
@@ -1,3 +1,4 @@ |
1 | 1 |
sources/*html |
2 | 2 |
sources/news.json |
3 |
+sources/gennews.log |
|
3 | 4 |
.*swp |
... | ... |
@@ -1,12 +1,29 @@ |
1 | 1 |
#!/bin/bash |
2 |
-cd /var/www/html/news/sources |
|
3 |
-echo "====== news.json" |
|
2 |
+OUTDIR="/var/www/html/news/sources" |
|
3 |
+LOG_ENABLED=1 |
|
4 |
+LOGFILE="$OUTDIR/gennews.log" |
|
5 |
+ |
|
6 |
+function log() { |
|
7 |
+ if [ 1 -eq $LOG_ENABLED ] |
|
8 |
+ then |
|
9 |
+ DATELOG=$(date) |
|
10 |
+ echo -e "$@" |
|
11 |
+ echo -e "$DATELOG $(basename $0): $@" >> $LOGFILE |
|
12 |
+ fi |
|
13 |
+} |
|
14 |
+ |
|
15 |
+ |
|
16 |
+ |
|
17 |
+cd $OUTDIR |
|
18 |
+log "====== news.json" |
|
4 | 19 |
php create-json.php > news.json 2> /dev/null |
5 | 20 |
#E.g : |
6 | 21 |
#php news-lemonde.fr.php > lemonde.html 2> /dev/null |
7 | 22 |
for gen in $(ls news-*|grep -v constants) |
8 | 23 |
do |
9 |
- echo "====== $gen" |
|
24 |
+ log "====== $gen" |
|
10 | 25 |
output=$(echo $gen|cut -d'-' -f2|cut -d'.' -f1).html |
11 |
- php $gen > $output 2> /dev/null |
|
26 |
+ php $gen > $output 2>> $LOGFILE |
|
12 | 27 |
done |
28 |
+log "Done." |
|
29 |
+log "==================================================================" |
... | ... |
@@ -65,7 +65,7 @@ foreach ($articles as $article ) { |
65 | 65 |
$article_only=DOMinnerHTML($articles[0]); |
66 | 66 |
} else { |
67 | 67 |
$article_only = "Extraction Failed"; |
68 |
- break; |
|
68 |
+ ERROR("article($cpt) : $article_only : ".$article['link']); |
|
69 | 69 |
} |
70 | 70 |
$figure=""; |
71 | 71 |
|