Don't set parser.encoding

Read-only property with new Beautiful Soup parser.
This commit is contained in:
Chris Mayo 2019-10-05 19:38:57 +01:00
parent 69d426b36f
commit 4f8c2954cf
3 changed files with 1 additions and 6 deletions

View file

@ -84,8 +84,6 @@ class HttpUrl (internpaturl.InternPatternUrl, proxysupport.ProxySupport):
handler = linkparse.MetaRobotsFinder() handler = linkparse.MetaRobotsFinder()
parser = htmlsax.parser(handler) parser = htmlsax.parser(handler)
handler.parser = parser handler.parser = parser
if self.charset:
parser.encoding = self.charset
# parse # parse
try: try:
parser.feed(self.get_raw_content()) parser.feed(self.get_raw_content())

View file

@ -89,14 +89,13 @@ class FormFinder(object):
self.form = None self.form = None
def search_form(content, cgiuser, cgipassword, encoding='utf-8'): def search_form(content, cgiuser, cgipassword):
"""Search for a HTML form in the given HTML content that has the given """Search for a HTML form in the given HTML content that has the given
CGI fields. If no form is found return None. CGI fields. If no form is found return None.
""" """
handler = FormFinder() handler = FormFinder()
parser = htmlsax.parser(handler) parser = htmlsax.parser(handler)
handler.parser = parser handler.parser = parser
parser.encoding = encoding
# parse # parse
parser.feed(content) parser.feed(content)
parser.flush() parser.flush()

View file

@ -125,8 +125,6 @@ def find_links (url_data, callback, tags):
# construct parser object # construct parser object
handler = linkparse.LinkFinder(callback, tags) handler = linkparse.LinkFinder(callback, tags)
parser = htmlsax.parser(handler) parser = htmlsax.parser(handler)
if url_data.charset:
parser.encoding = url_data.charset
handler.parser = parser handler.parser = parser
# parse # parse
try: try: