reload detail page in a loop
authorgregor herrmann <gregoa@debian.org>
Sun, 9 Apr 2017 17:04:49 +0000 (19:04 +0200)
committergregor herrmann <gregoa@debian.org>
Sun, 9 Apr 2017 17:04:49 +0000 (19:04 +0200)
up to 5 times until we get our cvs download link

bob_download.py

index 0511de86c3cab0322dfcb0dd688942cc940160fd..f979edbbc684cf898851d5f7f362de600e4ab041 100755 (executable)
@@ -90,9 +90,14 @@ def main(username, password, destdir, csv_format):
 #        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
-        time.sleep(5)
-        response = session.get(response.url)
         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
         response = session.get('https://rechnung.bob.at/obp/download.obp?fmt={}&table=obp.calls.table'.format(csv_format))
         assert response.ok