We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 98dc244 commit 3e313ffCopy full SHA for 3e313ff
Day66-75/code/image360/image360/spiders/taobao.py
@@ -1,5 +1,7 @@
1
# -*- coding: utf-8 -*-
2
+from io import StringIO
3
from urllib.parse import urlencode
4
+import re
5
6
import scrapy
7
@@ -26,6 +28,9 @@ def parse(self, response):
26
28
item = GoodsItem()
27
29
item['price'] = goods.xpath('div[5]/div[2]/div[1]/div[1]/strong/text()').extract_first()
30
item['deal'] = goods.xpath('div[5]/div[2]/div[1]/div[2]/text()').extract_first()
- item['title'] = goods.xpath('div[6]/div[2]/div[2]/a/text()').extract_first()
31
+ segments = goods.xpath('div[6]/div[2]/div[2]/a/text()').extract()
32
+ title = StringIO()
33
+ for segment in segments:
34
+ title.write(re.sub('\s', '', segment))
35
+ item['title'] = title.getvalue()
36
yield item
-
0 commit comments