#!/usr/bin/env bash # Copyright (C) 2019, Maxim Lihachev, # # 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, version 3. # # 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, see . # Получение последних записей с сайта vandrouki.ru declare -A URLS=( ["asia"]="https://vandrouki.asia" ["by"]="https://vandrouki.by" ["ru"]="https://vandrouki.ru" ) rstc="\033[00m" yellow="\033[1;33m" blue="\033[1;34m" green="\033[1;32m" get_info() { echo -e "$green>> $1 $rstc\n" curl -s -q "$1" \ | sed 's/&- \ | awk 'BEGIN { RS="" } { gsub(/\n+/, "@"); gsub(/

/, "\n"); gsub(/(href=")|(" rel=[^>]*>)|(published.>)/, "@"); gsub(/(&#[0-9]+;)|(<[^@>]*>*)/, ""); gsub(/@\s*@*/,"@"); gsub(/\r/,""); print }' \ | awk -F'@' -v blue="$blue" -v yellow="$yellow" -v green="$green" -v rstc="$rstc" ' /^\s*$/ { next } { if ($4 ~ /^\s*$/) { date = $5 } else { date = $4 } print blue " # " date "\t" yellow $3 "\n\t\t" green $2 rstc }' echo -e "\n--------------------------------\n" } domains="${*:-.}" filter=${domains// /|} if [[ "$filter" =~ -h|--h ]]; then echo "USAGE: $(basename "$0") ?domains? [ru, by, asia]" exit 0 fi for url in "${URLS[@]}"; do if [[ "$url" =~ $filter ]]; then get_info "$url" fi done