Iterating over a dictionary in python and stripping white space

后端 未结 7 579
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-13 01:10

I am working with the web scraping framework Scrapy and I am a bit of a noob when it comes to python. So I am wondering how do I iterate over all of the scraped items which

7条回答
  •  春和景丽
    2021-01-13 01:25

    Not a direct answer to the question, but I would suggest you look at Item Loaders and input/output processors. A lot of your cleanup can be take care of here.

    An example which strips each entry would be:

    class ItemLoader(ItemLoader):
    
        default_output_processor = MapCompose(unicode.strip)
    

提交回复
热议问题