Getting error while trying to get image path from website using scrapy

Getting error while trying to get image path from website using scrapy



I am new to scrapy and trying to scrape product from amazone. I able to get almost all data of single product but image path giving me error.



Error :


AttributeError: 'list' object has no attribute 'replace'



Code I am trying :



in items.py I have class and added this as well with other fields :


items.py


productImage = Field()



in other file test.py I have wrote like this to get image path :


test.py


productimage = hxs.select('(//li[contains(@class,"imageThumbnail")]//following-sibling::span[@class="a-button-text"]//img//@src)[1]').extract()
converter = html2text.HTML2Text()
converter.ignore_links = True
print("productImage :" + converter.handle(productimages))



I also tried :


productimage = hxs.select('(//li[contains(@class,"imageThumbnail")]//following-sibling::span[@class="a-button-text"]//img//@src)[1]').extract()[0]



Xpath is correct and I already evaluated it.





as the error says, productimage is a list, maybe try with productimage[0]
– eLRuLL
Aug 28 at 3:13


productimage


productimage[0]





@eLRuLL - No luck
– Helping Hands
Aug 28 at 3:15





What's the error with productimage[0]?
– Granitosaurus
Aug 28 at 4:00


productimage[0]





@Granitosaurus- There is no error in that case but it also did not print any data for image path
– Helping Hands
Aug 28 at 4:32





You have no replace() calls in your code related to image path. Obviously you have an error in another part of your test.py
– gangabass
Aug 28 at 7:50


replace()


test.py









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)