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

Popular posts from this blog

shopping cart - Page redirect not working PHP -

php - How to modify a menu to show sub-menus -

python - Installing PyDev in eclipse is failed -