scrapinghub / portia

Visual scraping for Scrapy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dynamic encoding possible for open and reading file or contents?

donni106 opened this issue · comments

We have an error for web pages that are not utf-8. Here is a code line (L325) which is affected:

def open(self, *args, **kwargs):
"""Open files from filesystem."""
raw = kwargs.pop('raw', False)
with open(self._path(*args), encoding = 'utf-8') as f:
return decode(f.read()) if raw else json.load(f)

Can this encoding be dynamic based on the web page or an option set for a web page in some configs?