Skip to content

Explicitly tell BeautifulSoup to pick "best available parser" #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions vbscraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import os
import os.path

html_parser = "html.parser" # let BeautifulSoup choose html parser

PostboxDocument = collections.namedtuple(
'PostboxDocument',
Expand Down Expand Up @@ -72,7 +73,7 @@ def login(self, username):
)

# Parse returned page
soup = bs4.BeautifulSoup(r.text)
soup = bs4.BeautifulSoup(r.text, html_parser)

if not soup.find(text='Finanzstatus'):
raise RuntimeError('Login to Volksbank Online Banking failed.')
Expand Down Expand Up @@ -111,7 +112,7 @@ def postbox_items(self):
r = self.s.get(self.base_url + self.postbox_url)

# Parse Postbox page
soup = bs4.BeautifulSoup(r.text)
soup = bs4.BeautifulSoup(r.text, html_parser)

# Get number of pages
li = soup.find('li', attrs={'class': 'gad-paginationActivePageNumber'})
Expand Down Expand Up @@ -181,7 +182,7 @@ def postbox_items(self):
r = self.s.get(self.base_url + a_next_page['href'])

# Parse Postbox page
soup = bs4.BeautifulSoup(r.text)
soup = bs4.BeautifulSoup(r.text, html_parser)

return ret

Expand All @@ -197,7 +198,7 @@ def download_document(self, document, destinations):
r = self.s.get(self.base_url + self.postbox_url)

# Parse Postbox page
soup = bs4.BeautifulSoup(r.text)
soup = bs4.BeautifulSoup(r.text, html_parser)

# Get current page number
li = soup.find(
Expand Down Expand Up @@ -227,7 +228,7 @@ def download_document(self, document, destinations):
r = self.s.get(self.base_url + document.url)

# parse message page
soup = bs4.BeautifulSoup(r.text)
soup = bs4.BeautifulSoup(r.text, html_parser)

#subject = msg_soup.find(
# 'label', attrs={'for': 'messageSenderSubject'}
Expand Down