I'm using casperjs to scrape a site. I setup a function which stores a string into a variable named images (shown below) and it works great.
images = casper.getElementsAttribute('.search-product-image','src');
I then call that variable in fs so I can export it to a CSV, which also works fine.
casper.then(function() {
var f = fs.open('e36v10.csv', 'w');
f.write(imagessplit + String.fromCharCode(13));
f.close();
});
The issue I just noticed is that not all products have images, so when the scraper hits a product without an image it passes by it obviously. I need it to at least alert me somehow (something as simple as filler text thats says, "no image here") when it passes by a product without an image because what I do is I copy that string (along with may other strings) and organize them into columns within the CSV and it messes up the order of everything without having some sort of filler text ("no image here"). Thanks
Edit
Below is the exact source from the website I am trying to pull from.
A product I can get the image from and my code works fine:
<div class="search-v4-product-image">
<img alt="238692" class="search-product-image" src="http://d5otzd52uv6zz.cloudfront.net/group.jpg">
<p class="image-overlay">Generic</p>
</div>
A product with no image and my scraper passes right by it without alerting me.
<div class="search-v4-product-image"> </div>