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.
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.
as the error says,
productimage
is a list, maybe try withproductimage[0]
– eLRuLL
Aug 28 at 3:13