Python Forum

Full Version: Scrapy Picking What to Output Href or Img
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi again guys,

Actually two things I want to ask help for (All of this are just inside the 'a' tag):

First one is:
I want to have a few items that I would like to output on a csv file.
href
inner-text and/or text
rel='no-follow'. And how would I have it write to a csv file if it did not see this then print to a csv 'do-follow'
img tag, how can I print or output 'img' if the spider see the a-link and see it's a 'img' type link?
All of these are inside the 'item'.

Second one is:
I usually see scraping things and using the 'item ='. Can I do a conditional like ifElse and the others since it's inside a define function?

To give an example:
Quote:<a href="http://myexampledomain.com"><img src='/example.jpg' alt='my inner text'>

How can I dissect and output each on my csv file?
href
img (output text on my csv is 'img')
alt or inner text

Sorry if these isn't just one question.

Many thanks for the help and enlightenment. Smile
It would be a very big help if anyone can help me out?