-#!/bin/sh
+#!/bin/bash
-FROM=54696
+FROM=1
#FROM=190000
-UNTIL=55060
+UNTIL=1000000
#UNTIL=200000
cat <<EOF
2. Visit https://dvr.dsk.gv.at/at.gv.bka.dvr.public/DVRRecherche.aspx and
search for "Bundeskanzleramt" in "Auftraggeber". Then press
"Datenanwendung". This is important in order to fetch the purposes too!
-3. Loof for a cookie from "dvr.dsk.gv.at" named "ASP.NET_SessionId". Copy its
+3. Look for a cookie from "dvr.dsk.gv.at" named "ASP.NET_SessionId". Copy its
content in this script at the curresponding curl line.
EOF
-for id in `seq ${FROM} ${UNTIL}`; do
-
+COOKIE_SESSION_ID=0ckafib0jrhs3ayhd3m55bv0
+
+pause
+
+for id in $(seq ${FROM} ${UNTIL}); do
echo -n "### ID ${id}"
FN="dump/$id.html.gz"
if ! [ -e "${FN}" ]; then
echo -n " Fetching..."
- curl -s -b ASP.NET_SessionId=0ckafib0jrhs3ayhd3m55bv0 \
+ curl -s -b ASP.NET_SessionId=${COOKIE_SESSION_ID} \
"https://dvr.dsk.gv.at/at.gv.bka.dvr.public/AuftraggeberDetail.aspx?Id=${id}" | gzip > "${FN}"
# Do not stress server too much
"""Manages a list of geolocation providers."""
providers = [
- GoogleGeolocation(),
- BingGeolocation()
- ]
+ GoogleGeolocation(),
+ BingGeolocation()
+ ]
@staticmethod
def isNameValid(name):
@staticmethod
def getByIndex(idx):
"""Get provider by index"""
- assert(GeolocationProviders.isIndexValid(idx))
+ assert (GeolocationProviders.isIndexValid(idx))
return GeolocationProviders.providers[idx]
@staticmethod
def getIndexByName(name):
"""Get provider by its name"""
- assert(GeolocationProviders.isNameValid(name))
+ assert (GeolocationProviders.isNameValid(name))
return [p.name().lower() for p in GeolocationProviders.providers].index(name.lower())
+
class Database:
"""Encapsualtes a DVR database."""
def get_geolocation(self, dvrid, provider):
"""Return geolocation of given DVR-ID and provider."""
- assert(GeolocationProviders.isIndexValid(provider))
+ assert (GeolocationProviders.isIndexValid(provider))
c = self.conn.cursor()
- c.execute("SELECT * FROM geolocations WHERE dvrid=? AND provider=?", \
+ c.execute("SELECT * FROM geolocations WHERE dvrid=? AND provider=?",
(dvrid, provider))
res = c.fetchone()
if res is None:
def add_geolocation(self, dvrid, provider, lat, lon):
"""Add a geolocatoin for a given DVR-ID."""
- assert(GeolocationProviders.isIndexValid(provider))
+ assert (GeolocationProviders.isIndexValid(provider))
c = self.conn.cursor()
- c.execute("INSERT INTO geolocations VALUES (?, ?, ?, ?)", \
+ c.execute("INSERT INTO geolocations VALUES (?, ?, ?, ?)",
(dvrid, provider, lat, lon))
c.close()
self.conn.commit()
for (dirpath, dirnames, filenames) in os.walk(source):
for f in filenames:
if f.endswith(".html") or f.endswith(".html.gz"):
- p = os.path.join(dirpath,f)
+ p = os.path.join(dirpath, f)
processAdd(db, p)
else:
print("What the hell is '%s'?" % source, file=sys.stderr)
maptemplatefn = arg
else:
print("Unknown option '", opt, "'.", file=sys.stderr)
- assert(False)
+ assert (False)
except getopt.GetoptError as e:
print("Error parsing arguments:", e, file=sys.stderr)