Skip to content

Instantly share code, notes, and snippets.

@nyov
Created May 21, 2014 04:33
Show Gist options
  • Save nyov/2f8bcdd656b2ee785422 to your computer and use it in GitHub Desktop.
Save nyov/2f8bcdd656b2ee785422 to your computer and use it in GitHub Desktop.
(scrapy) use a custom html string as new response body
from scrapy.http import HtmlResponse
def parse(self, response):
body = cc_stripped(response.body) # modifyor get new response.body
response = HtmlResponse(response.url,
encoding='utf-8',
body=body.decode('utf-8'),
)
sel = Selector(response)
[...]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment