Mayank Rastogi
Mayank Rastogi

Reputation: 35

TypeError: a bytes-like object is required, not 'str' in python 3.5

I am learning data scraping in python 3.5 and trying to find the existence of a word on website, i am getting error:

TypeError: a bytes-like object is required, not 'str'

 pyladies_source = uReq("http://pyladies.com")
 pyladies_source = pyladies_source.read()
'python' in pyladies_source

Upvotes: 0

Views: 600

Answers (1)

user3483203
user3483203

Reputation: 51165

pyladies_source = uReq("http://pyladies.com")
pyladies_source = pyladies_source.read()
'python' in str(pyladies_source) # Returns false in this case, at least when I ran it.

All you had to change was casting pyladies_source to a string so you can look for 'python'

Upvotes: 1

Related Questions