Pastebin
API
tools
faq
paste
Login
Sign up
Please fix the following errors:
New Paste
Syntax Highlighting
#!/bin/bash # New version: https://github.com/Fabian42/bash_scripts/blob/main/corona.sh # Feedback: fabianroeling@googlemail.com # maybe TODO for reliability & less effort: translate into Google Sheets script? worldometers(){ # $1 is the number of leading rows to remove for alignment of all tables on 2020-05-25 # $2 is the series name to be searched # find series name on website, get number list ("data"), remove prefix, remove suffix, "null"→"0", negatives→0, split on commas, align to 2020-05-25 echo -n "$page" | grep -im 1 --after-context=5 "name: '$2'" | grep "data" | sed -E "s/ *data\\: \\[//" | sed -E "s/\\] *\\} *\\]? *\\,? *\\{? *//" | sed -E "s/null/0/g" | sed -E "s/\\-[0-9]+/0/g" | sed -E "s/\\,/\\n/g" | tail -n +$1 } ### START # open sheet (firefox "docs.google.com/spreadsheets/d/1uDTghO_ZYBs5nfs2kDc0Ms6e9bbx7clx_QgkWii7OMY" &> /dev/null & disown) # print old state in case something goes wrong cat ~/misc/corona_storage echo # Hannover cases and deaths, Lehrte cases and new (first because of highest probability of failure) # This breaks if 20 or more articles were published today after the Corona update. I could fix that, but it's extremely unlikely. Changes to the website break stuff way more often. # In case of a missed day: Replace »$(date "+%Y\\/%m\\/%d")« with e.g. »2021\\/03\\/29« links=$(wget --no-check-certificate -qO - "www.altkreisblitz.de/region-hannover" | grep -E "<div class\\=\\\"news\\-list\\-item\\-title\\\"><h2><a href\\=\\\"https\\:\\/\\/www\\.altkreisblitz\\.de\\/aktuelles\\/datum\\/$(date "+%Y\\/%m\\/%d")" | grep -Eo "https[^\\\"]+") found=0 for link in $links; do # $links not quoted, because that makes it only one long string page=$(wget -qO - "$link" | sed -E "s/\\r\\n?/\\n/g") # find HTML line with current cases table, remove everything before title (might include another table), take top value (yesterday), remove date temp=$(echo -n "$page" | grep --after-context=1 -Ee "Aktuell( |\\ \\;)+*Infizierte.*" -e "Aktuell( |\\ \\;)+registrierte( |\\ \\;)+Infizierte.*" | sed -E "s/.*Aktuell( |\\ \\;)+//" | grep -Eo "[0-9]+\\.[0-9]+\\.[0-9]*\\:( |\\ \\;)+[0-9\\.]+" | head -n 1 | sed -E "s/[0-9]+\\.[0-9]+\\.[0-9]*\\:( |\\ \\;)+//" | sed -E "s/\\.//") if [[ "$temp" != "" ]]; then cases_hannover="$temp" temp="" fi # find new cases sentence, extract number, convert words into numbers # They keep finding new ways to break my script, dammit. Who knows what they'll do for 0. This code used to look so clean… temp=$(echo -n "$page" | grep -Eom 1 "Menschen( |\ \;)+registriert\\,( |\ \;)+die( |\ \;)+sich( |\ \;)+in( |\ \;)+der( |\ \;)+Region( |\ \;)+mit( |\ \;)+dem( |\ \;)+Coronavirus( |\ \;)+infiziert( |\ \;)+haben\\.( |\ \;)+Das( |\ \;)+(sind|ist)( |\ \;)+[0-9a-zöü\\.]+( |\ \;)+(Fälle|Fall)( |\ \;)+mehr( |\ \;)+als" | sed -E "s/Menschen( |\ \;)+registriert\\,( |\ \;)+die( |\ \;)+sich( |\ \;)+in( |\ \;)+der( |\ \;)+Region( |\ \;)+mit( |\ \;)+dem( |\ \;)+Coronavirus( |\ \;)+infiziert( |\ \;)+haben\\.( |\ \;)+Das( |\ \;)+(sind|ist)( |\ \;)+//" | sed -E "s/( |\ \;)+(Fälle|Fall)( |\ \;)+mehr( |\ \;)+als//" | sed -E "s/\\.//" | sed -E "s/zwei/2/" | sed -E "s/drei/3/" | sed -E "s/vier/4/" | sed -E "s/fünf/5/" | sed -E "s/sechs/6/" | sed -E "s/sieben/7/" | sed -E "s/acht/8/" | sed -E "s/neun/9/" | sed -E "s/zehn/10/" | sed -E "s/elf/11/" | sed -E "s/zwölf/12/") # if numbers got corrected downwards, fallback to 0 new cases if [[ "$temp" == "" && "$(echo -n "$page" | grep -Eo "Menschen( |\ \;)+registriert\\,( |\ \;)+die( |\ \;)+sich( |\ \;)+in( |\ \;)+der( |\ \;)+Region( |\ \;)+mit( |\ \;)+dem( |\ \;)+Coronavirus( |\ \;)+infiziert( |\ \;)+haben\\.( |\ \;)+Das( |\ \;)+(sind|ist)( |\ \;)+[0-9a-zöü\\.]+( |\ \;)+(Fälle|Fall)( |\ \;)+weniger( |\ \;)+als")" != "" ]]; then temp=0 fi if [[ "$temp" != "" ]]; then new_cases_hannover="$temp" temp="" fi # find (total) deaths sentence, extract number temp=$(echo -n "$page" | grep -Eo "[0-9\\.]+( |\ \;)+Menschen( |\ \;)+sind( |\ \;)+infolge( |\ \;)+einer( |\ \;)+nachgewiesenen( |\ \;)+oder( |\ \;)+mutmaßlichen( |\ \;)+Corona\\-Infektion( |\ \;)+in( |\ \;)+der( |\ \;)+Region( |\ \;)+verstorben" | grep -Eo "[0-9\\.]+" | sed -E "s/\\.//") if [[ "$temp" != "" ]]; then dead_hannover_now="$temp" # calculate difference from previous saved value deaths_hannover=$(qalc -t "$dead_hannover_now-$(cat ~/misc/corona_storage | head -n 1)" | sed -E "s/−[0-9]+/0/" | sed -E "s/\"//g") temp="" fi # find current cases Lehrte based on some super specific HTML formatting (may break any day), extract number temp=$(echo -n "$page" | grep -Eo "Lehrte<\\/p>( |\ \;)*<\\/td>( |\ \;)*<td>( |\ \;)*<p class\\=\\\"bodytext\\\">( |\ \;)*[0-9\\.]+" | grep -Eo "[0-9\\.]+" | sed -E "s/\\.//") if [[ "$temp" != "" ]]; then cases_lehrte="$temp" temp="" fi # even more specific HTML formatting, wider range behind it, get last/second number temp=$(echo -n "$page" | grep -Eo "Lehrte<\\/p>( |\ \;)*<\\/td>( |\ \;)*<td>( |\ \;)*<p class\\=\\\"bodytext\\\">( |\ \;)*[0-9\\.]+( |\ \;)*<\\/p>( |\ \;)*<\\/td>( |\ \;)*<td>( |\ \;)*<p class\\=\\\"bodytext\\\">( |\ \;)*[0-9\\.]+" | grep -Eo "[0-9\\.]+" | tail -n 1 | sed -E "s/\\.//") if [[ "$temp" != "" ]]; then total_lehrte="$temp" # calculate difference from previous saved value new_cases_lehrte=$(qalc -t "$total_lehrte-$(cat ~/misc/corona_storage | tail -n 1)" | sed -E "s/−[0-9]+/0/" | sed -E "s/\\\"//g") fi if [[ "$cases_hannover" != "" ]] && [[ "$new_cases_hannover" != "" ]] && [[ "$dead_hannover_now" != "" ]] && [[ "$cases_lehrte" != "" ]] && [[ "$total_lehrte" != "" ]]; then found=1 break fi done if [[ $found == 1 ]]; then echo "found" else echo -e "Couldn't find/parse article, skipping. Links checked:\n$links" dead_hannover_now=$(cat ~/misc/corona_storage | head -n 1) total_lehrte=$(cat ~/misc/corona_storage | tail -n 1) echo "cases_hannover: $cases_hannover" echo "new_cases_hannover: $new_cases_hannover" echo "(dead_hannover_now: $dead_hannover_now)" echo "deaths_hannover: $deaths_hannover" echo "cases_lehrte: $cases_lehrte" echo "(total_lehrte: $total_lehrte)" echo "new_cases_lehrte: $new_cases_lehrte" echo fi # vaccination de, world, at page=$(wget -qO - "https://raw.githubusercontent.com/owid/covid-19-data/master/public/data/vaccinations/vaccinations.csv") # get area-specific rows, start at 2021-01-15, extract 6th column vaccination_de=$(echo -n "$page" | grep "Germany" | tail -n +22 | sed -E "s/([^\,]+\,){5}([^\,]+)\,.+/\2/") vaccination_world=$(echo -n "$page" | grep "World" | tail -n +47 | sed -E "s/([^\,]+\,){5}([^\,]+)\,.+/\2/") vaccination_at=$(echo -n "$page" | grep "Austria" | tail -n +22 | sed -E "s/([^\,]+\,){5}([^\,]+)\,.+/\2/") # vaccination Saxony # temporary file, because "7z -si" seems broken wget -qO /tmp/co "https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquotenmonitoring.xlsx?__blob=publicationFile" vaccination_saxony=$(7z e -so /tmp/co xl/worksheets/sheet2.xml | grep -Eo "r\=\"E16\" s\=\"[0-9]+\"><v>[0-9]+" | sed -E "s/r\=\"E16\" s\=\"[0-9]+\"><v>//") rm /tmp/co # vaccination North Saxony #page=$(wget -qO - "coronavirus.sachsen.de/ueberblick-coronaschutzimpfungen-in-sachsen-9874.html") #vaccination_north_saxony=$(echo -n "$page" | grep --after-context=2 "Nordsachsen" | grep -Eo "[0-9\\.]+" | tail -n 1 | sed -E "s/\\.//g") # Germany page=$(wget -qO - "worldometers.info/coronavirus/country/germany") cases_de=$(worldometers 101 "Currently infected") new_cases_de=$(worldometers 101 "New cases") deaths_de=$(worldometers 101 "Daily deaths") # world page=$(wget -qO - "worldometers.info/coronavirus") cases_world=$(worldometers 125 "Currently infected") new_cases_world=$(worldometers 125 "Daily cases") # yay for consistency deaths_world=$(worldometers 125 "Daily deaths") # Austria page=$(wget -qO - "worldometers.info/coronavirus/country/austria") cases_at=$(worldometers 101 "Currently infected") new_cases_at=$(worldometers 101 "New cases") deaths_at=$(worldometers 101 "Daily deaths") # if not found and not weekend, open page for manual check weekday=$(qalc -t "weekday(today)" | sed -E "s/\\\"//g") if [[ $found == 0 ]] && [[ $weekday -lt 6 ]]; then (firefox "www.altkreisblitz.de/region-hannover" &> /dev/null & disown) else # focus latest console window, hopefully that's the one with this script wmctrl -ia $(wmctrl -l | grep "Konsole" | tail -n 1 | sed -E "s/ .+//") fi # output to clipboard for overwriting all or to console for appending one entry echo -n "$vaccination_de" | xclip -selection clipboard; echo "paste vaccination_de" if [[ $weekday == 5 ]]; then echo -n "$vaccination_saxony"", ""$vaccination_saxony"", ""$vaccination_saxony"; read else echo -n "$vaccination_saxony"; read fi #echo -n "$vaccination_north_saxony"; read echo -n "$vaccination_world" | xclip -selection clipboard; echo -n "paste vaccination_world"; read echo -n "$vaccination_at" | xclip -selection clipboard; echo -n "paste vaccination_at"; read echo -n "$cases_de" | xclip -selection clipboard; echo -n "paste cases_de"; read echo -n "$new_cases_de" | xclip -selection clipboard; echo -n "paste new_cases_de"; read echo -n "$deaths_de" | xclip -selection clipboard; echo -n "paste deaths_de"; read echo -n "$cases_world" | xclip -selection clipboard; echo -n "paste cases_world"; read echo -n "$new_cases_world" | xclip -selection clipboard; echo -n "paste new_cases_world"; read echo -n "$deaths_world" | xclip -selection clipboard; echo "paste deaths_world" if [[ $found == 1 ]]; then if [[ $weekday == 5 ]]; then echo "$cases_hannover"", ""$cases_hannover"", ""$cases_hannover" echo "$new_cases_hannover"", 0, 0" echo "$deaths_hannover"", 0, 0" echo "$cases_lehrte"", ""$cases_lehrte"", ""$cases_lehrte" echo -n "$new_cases_lehrte"", 0, 0" else echo "$cases_hannover" echo "$new_cases_hannover" echo "$deaths_hannover" echo "$cases_lehrte" echo -n "$new_cases_lehrte" fi else echo -n "copy, 0, 0, copy, 0 (or see above)" fi read echo -n "$cases_at" | xclip -selection clipboard; echo -n "paste cases_at"; read echo -n "$new_cases_at" | xclip -selection clipboard; echo -n "paste new_cases_at"; read echo -n "$deaths_at" | xclip -selection clipboard; echo "paste deaths_at" echo -en "$dead_hannover_now\n$total_lehrte" > ~/misc/corona_storage
Optional Paste Settings
Category:
None
Cryptocurrency
Cybersecurity
Fixit
Food
Gaming
Haiku
Help
History
Housing
Jokes
Legal
Money
Movies
Music
Pets
Photo
Science
Software
Source Code
Spirit
Sports
Travel
TV
Writing
Tags:
Syntax Highlighting:
None
Bash
C
C#
C++
CSS
HTML
JSON
Java
JavaScript
Lua
Markdown (PRO members only)
Objective C
PHP
Perl
Python
Ruby
Swift
4CS
6502 ACME Cross Assembler
6502 Kick Assembler
6502 TASM/64TASS
ABAP
AIMMS
ALGOL 68
APT Sources
ARM
ASM (NASM)
ASP
ActionScript
ActionScript 3
Ada
Apache Log
AppleScript
Arduino
Asymptote
AutoIt
Autohotkey
Avisynth
Awk
BASCOM AVR
BNF
BOO
Bash
Basic4GL
Batch
BibTeX
Blitz Basic
Blitz3D
BlitzMax
BrainFuck
C
C (WinAPI)
C Intermediate Language
C for Macs
C#
C++
C++ (WinAPI)
C++ (with Qt extensions)
C: Loadrunner
CAD DCL
CAD Lisp
CFDG
CMake
COBOL
CSS
Ceylon
ChaiScript
Chapel
Clojure
Clone C
Clone C++
CoffeeScript
ColdFusion
Cuesheet
D
DCL
DCPU-16
DCS
DIV
DOT
Dart
Delphi
Delphi Prism (Oxygene)
Diff
E
ECMAScript
EPC
Easytrieve
Eiffel
Email
Erlang
Euphoria
F#
FO Language
Falcon
Filemaker
Formula One
Fortran
FreeBasic
FreeSWITCH
GAMBAS
GDB
GDScript
Game Maker
Genero
Genie
GetText
Go
Godot GLSL
Groovy
GwBasic
HQ9 Plus
HTML
HTML 5
Haskell
Haxe
HicEst
IDL
INI file
INTERCAL
IO
ISPF Panel Definition
Icon
Inno Script
J
JCL
JSON
Java
Java 5
JavaScript
Julia
KSP (Kontakt Script)
KiXtart
Kotlin
LDIF
LLVM
LOL Code
LScript
Latex
Liberty BASIC
Linden Scripting
Lisp
Loco Basic
Logtalk
Lotus Formulas
Lotus Script
Lua
M68000 Assembler
MIX Assembler
MK-61/52
MPASM
MXML
MagikSF
Make
MapBasic
Markdown (PRO members only)
MatLab
Mercury
MetaPost
Modula 2
Modula 3
Motorola 68000 HiSoft Dev
MySQL
Nagios
NetRexx
Nginx
Nim
NullSoft Installer
OCaml
OCaml Brief
Oberon 2
Objeck Programming Langua
Objective C
Octave
Open Object Rexx
OpenBSD PACKET FILTER
OpenGL Shading
Openoffice BASIC
Oracle 11
Oracle 8
Oz
PARI/GP
PCRE
PHP
PHP Brief
PL/I
PL/SQL
POV-Ray
ParaSail
Pascal
Pawn
Per
Perl
Perl 6
Phix
Pic 16
Pike
Pixel Bender
PostScript
PostgreSQL
PowerBuilder
PowerShell
ProFTPd
Progress
Prolog
Properties
ProvideX
Puppet
PureBasic
PyCon
Python
Python for S60
QBasic
QML
R
RBScript
REBOL
REG
RPM Spec
Racket
Rails
Rexx
Robots
Roff Manpage
Ruby
Ruby Gnuplot
Rust
SAS
SCL
SPARK
SPARQL
SQF
SQL
SSH Config
Scala
Scheme
Scilab
SdlBasic
Smalltalk
Smarty
StandardML
StoneScript
SuperCollider
Swift
SystemVerilog
T-SQL
TCL
TeXgraph
Tera Term
TypeScript
TypoScript
UPC
Unicon
UnrealScript
Urbi
VB.NET
VBScript
VHDL
VIM
Vala
Vedit
VeriLog
Visual Pro Log
VisualBasic
VisualFoxPro
WHOIS
WhiteSpace
Winbatch
XBasic
XML
XPP
Xojo
Xorg Config
YAML
YARA
Z80 Assembler
ZXBasic
autoconf
jQuery
mIRC
newLISP
q/kdb+
thinBasic
Paste Expiration:
Never
Burn after read
10 Minutes
1 Hour
1 Day
1 Week
2 Weeks
1 Month
6 Months
1 Year
Paste Exposure:
Public
Unlisted
Private
Folder:
(members only)
Password
NEW
Enabled
Disabled
Burn after read
NEW
Paste Name / Title:
Create New Paste
Hello
Guest
Sign Up
or
Login
Sign in with Facebook
Sign in with Twitter
Sign in with Google
You are currently not logged in, this means you can not edit or delete anything you paste.
Sign Up
or
Login
Public Pastes
I made $15,000 in 2 days
CSS | 11 min ago | 0.21 KB
This summer smells like money
CSS | 12 min ago | 0.21 KB
✅ API Glitch (Docs Leak)
CSS | 12 min ago | 0.21 KB
Untitled
mIRC | 2 hours ago | 0.57 KB
ifm isu iolink [WIP]
Python | 3 hours ago | 1.18 KB
HELLO PROGRAMMER
17 hours ago | 0.03 KB
Untitled
22 hours ago | 2.26 KB
FB2600 User Handbook v0.91
1 day ago | 6.06 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the
Cookies Policy
.
OK, I Understand
Not a member of Pastebin yet?
Sign Up
, it unlocks many cool features!