Skip to content

Troubleshooting

movabo edited this page Oct 21, 2016 · 1 revision

Troubleshooting

TypeError: cannot use a string pattern on a bytes-like object

If you receive an error like

TypeError: cannot use a string pattern on a bytes-like object

You need to go to the last file in the traceback which is located in this project. Example:

Traceback (most recent call last):
  File "./single_crawler.py", line 222, in <module>
    daemonize=sys.argv[5])
  File "./single_crawler.py", line 90, in __init__
    crawler_class = self.get_crawler(self.crawler, site["url"])
  File "./single_crawler.py", line 151, in get_crawler
    if supports_site(url):
  File "./newscrawler/crawler/spiders/rss_crawler.py", line 101, in supports_site
    response) is not None
  File "/usr/lib/python3.5/re.py", line 173, in search
    return _compile(pattern, flags).search(string)
TypeError: cannot use a string pattern on a bytes-like object

Here you need to go to ./newscrawler/crawler/spiders/rss_crawler.py, line 101. The problem is, that (in this case response) is an byte-string. So this string needs to be transformed to a normal string. To do so, just replace response in line 101 with response.decode('utf-8')

  • [I am a developer](I am a developer)
  • [I am a user](I am a user)

Setup

Crawlers / Spiders

System design

Further Documentation

Clone this wiki locally