0

crawl.py. I try to port it to python3. I leave out all unnecessary details. Error:

Traceback (most recent call last):
  File "crawl.py", line 44, in parseAndGetLinks
    self.parser = html.parser(AbstractFormatter(DumbWriter(StringIO())))
TypeError: 'module' object is not callable


import html.parser  
from formatter import DumbWriter, AbstractFormatter  
from io  import StringIO     

parser = html.parser(AbstractFormatter(DumbWriter(StringIO())))
0

1 Answer 1

5

html.parser is the module; you want the HTMLParser class in that module:

parser = html.parser.HTMLParser(AbstractFormatter(DumbWriter(StringIO())))

or more succinctly:

from html.parser import HTMLParser

parser = HTMLParser(AbstractFormatter(DumbWriter(StringIO())))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.