Skip to content

Instantly share code, notes, and snippets.

@nyov
Created February 1, 2014 01:00
Show Gist options
  • Save nyov/8746440 to your computer and use it in GitHub Desktop.
Save nyov/8746440 to your computer and use it in GitHub Desktop.
def cc_stripped(x, extended=False):
""" strip control characters from string """
if extended:
# also strip extended characters
return "".join([i for i in x if ord(i) in range(32, 126)])
return "".join([i for i in x if ord(i) in range(32, 127)])
def parse(self, response):
body = cc_stripped(response.body)
response = HtmlResponse(response.url,
encoding='utf-8'
body=body.decode('utf-8'),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment