0
votes

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
1
It sounds like the type of pyladies_source is in bytes - user3483203
Have you tried str()? - Simon
can you tell me the code for the solution, i not that proficient in python - Mayank Rastogi
In the future, please provide your imports when you use custom naming for imports. For example, show that you used from urllib.request import urlopen as uReq - user3483203

1 Answers

1
votes
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'