Skip to content

From lesson "HTML to List of Words (part 2)" - Find command does not work (obo.py) #1701

@grabani

Description

@grabani

Running the 'html-to-list1.py' file from the 'python-lessons3.zip' I get the following error:

TypeError: argument should be integer or bytes-like object, not 'str'

The full title of the lesson
Lesson Tile: From HTML to List of Words (part 2)

  • The system you are using (Mac, Linux, Windows)
    System = Windows
  • Version numbers of the relevant software you are using
    Python = 3.7.6
    Windows = 10
  • The exact steps you took that caused the problem
    C:\Users\joe\Desktop\python-lessons3>python html-to-list1.py
    Traceback (most recent call last):
    File "html-to-list1.py", line 8, in
    text = obo.stripTags(html)
    File "C:\Users\grabani\Desktop\python-lessons3\obo.py", line 3, in stripTags
    startLoc = pageContents.find("

    ")
    _TypeError: argument should be integer or bytes-like object, not 'str'
    _

It would seem that in the obo.py module, a call to the find command fails as it is acting upon a binary type (i.e. 'pageContents' is of type 'binary) whilst the find command requires a string to act upon.

I have managed to overcome this limitation by converting 'pageContents' to string using the syntax 'pageContents= str(pageContents)'. However, as I am working with text other than english this is causing me issues later on.

PS - Great site. Has proven to be a useful resource.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions