kichik / email-scraper

Simple Python library to scrape email addresses from HTML
MIT License
21 stars 10 forks source link

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

Closed sbaginski closed 3 years ago

sbaginski commented 3 years ago

I found the following error:

File "C:\Python38\lib\site-packages\email_scraper\scrape.py", line 68, in scrape_emails
    return set(extract_emails(deobfuscate_html(html)))
  File "C:\Python38\lib\site-packages\email_scraper\scrape.py", line 55, in deobfuscate_html
    html = unescape(html)
  File "C:\Python38\lib\site-packages\email_scraper\scrape.py", line 46, in unescape
    return html.unescape(html_text)
  File "C:\Python38\lib\html\__init__.py", line 130, in unescape
    if '&' not in s:
TypeError: a bytes-like object is required, not 'str'

I use scrape_emails in the following way, so if I'm doing something wrong please inform me, thanks!

page = requests.get(url)
results = scrape_emails(page.content)
kichik commented 3 years ago

Use r.text instead of r.content.