Remove page reloads.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 19 Apr 2017 18:21:21 +0000 (20:21 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Wed, 19 Apr 2017 18:21:21 +0000 (20:21 +0200)
bob_download.py

index c57876deb87b0ff8dc720461a7727797a81b5ccc..242f184563be5940a659f8fe037a7c8eca264dd8 100755 (executable)
@@ -73,26 +73,15 @@ def main(username, password, destdir, csv_format):
                 file.write(response.content)
 
     # Download CSVs
-    # Links look like '/bill.ctn.cdr.obp?bsn=116'
+    # e.g. https://rechnung.bob.at/bill.ctn.cdr.obp?bsn=79
     regexp = re.compile(r'\/bill.ctn.cdr.obp\?')
     links = html.findAll('a', href=regexp)
     for link in links:
         url = link['href']
-        response = session.get(urljoin(response.url, url))
+        response = session.get(urljoin(response.url, url))  # e.g. 'https://rechnung.bob.at/bill.ctn.cdr.obp?bsn=79'
         assert response.ok
-#        assert 'OBP.utils.reloadAfterDelay("/bill.ctn.cdr.set.obp",5);' in response.text
-#        time.sleep(5) # OBP.utils.reloadAfterDelay("/bill.ctn.cdr.set.obp",5);
-#        response = session.get(urljoin(response.url, 'bill.ctn.cdr.set.obp'))
-#        assert 'OBP.utils.reloadAfterDelay("/bill.ctn.cdr.set.obp",5);' not in response.text
         html = BeautifulSoup(response.text, 'html.parser')
-        tries = 0
-        while not html.find('a', id='link_csv_download') and tries < 5:
-            tries = tries + 1
-            time.sleep(5)
-            response = session.get(response.url)
-            assert response.ok
-            html = BeautifulSoup(response.text, 'html.parser')
-        assert html.find('a', id='link_csv_download') is not None
+        assert html.find('a', id='link_csv_download')
         response = session.get('https://rechnung.bob.at/obp/download.obp?fmt={}&table=obp.calls.table'.format(csv_format))
         assert response.ok
         filename = response.headers['Content-Disposition'].split('=')[1] # e.g. 'EVN_1509_523260091_1_069911934859.txt'