代碼 :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()}運(yùn)行命令(Windows 10):scrapy runspider C:\Users\DELL\Desktop\icscrape\bijouterie.py -o posts.csvCSV 文件: https: //pastebin.com/qEQTKEcC我只想抓取文本而不是整個(gè) html 類代碼。
1 回答

Smart貓小萌
TA貢獻(xiàn)1911條經(jīng)驗(yàn) 獲得超7個(gè)贊
只需在 css 選擇器末尾添加 (::text) 即可,例如
{'title': post.css('a.moodalbox.response::text').get()}
添加回答
舉報(bào)
0/150
提交
取消