python - How to convert string into response object in scrapy? -
i want convert string contains html tags can use selectors extract few information. i'm getting html in json response. i've used htmlparser i'm getting error exceptions.typeerror: cannot create weak reference 'unicode' object
my code is:
sel = selector(response) jsonresponse = json.loads(response.body_as_unicode()) hello= jsonresponse["html"].encode('ascii','ignore') h = htmlparser.htmlparser() world=h.unescape(hello) sel1 = selector(world)
i got answer:
i needed mention text while using selectors in case response string.
sel = selector(response) jsonresponse = json.loads(response.body_as_unicode()) hello= jsonresponse["html"].encode('ascii','ignore') sel1 = selector(text=hello)
Comments
Post a Comment