代码 :import scrapyclass BlogSpider(scrapy.Spider): name = 'bijouterie' start_urls = ['https://www.example.com'] def parse(self, response): for post in response.css('#engine-results .drs'): yield {'title': post.css('a.moodalbox.response').get()}运行命令(Windows 10):scrapy runspider C:\Users\DELL\Desktop\icscrape\bijouterie.py -o posts.csvCSV 文件: https: //pastebin.com/qEQTKEcC我只想抓取文本而不是整个 html 类代码。
1 回答
![?](http://img1.sycdn.imooc.com/54584ee0000179f302200220-100-100.jpg)
Smart猫小萌
TA贡献1911条经验 获得超7个赞
只需在 css 选择器末尾添加 (::text) 即可,例如
{'title': post.css('a.moodalbox.response::text').get()}
添加回答
举报
0/150
提交
取消