@@ -67,14 +67,18 @@ def parse_model_selling(self, response):
6767
6868 models = panel [i * 2 + 1 ]
6969 for model in models .xpath ('li' ):
70- model_name = model .xpath ('div/div/p/a/text()' ).extract ()
71- model_id = model .xpath ('div/div/p/@data-gcjid' ).extract ()
70+ model_name = model .xpath ('div[@class="interval01-list-cars"]/div/p/a/text()' )[0 ].extract ()
71+ model_id = model .xpath ('div[@class="interval01-list-cars"]/div/p/@data-gcjid' )[0 ].extract ()
72+ price = model .xpath ('div[@class="interval01-list-guidance"]/div/text()' )[0 ].re (r'(\d+\.\d+)' )
73+ if not price :
74+ price = model .xpath ('div[@class="interval01-list-guidance"]/div/text()' )[1 ].re (r'(\d+\.\d+)' )
7275
7376 model = ModelItem ()
7477 model ['id' ] = model_id
7578 model ['name' ] = model_name
7679 model ['series_id' ] = series_id
7780 model ['group' ] = group
81+ model ['price' ] = price
7882 yield model
7983 count += 1
8084
@@ -103,15 +107,20 @@ def parse_model_selling(self, response):
103107 else :
104108 log .msg ('[parse_selling] is not selling.' )
105109 count = 0
106- model_tags = response .xpath ('//td[@class="name_d"]/a' )
110+ model_tags = response .xpath ('//table/tboby/tr' )
111+ if not model_tags or len (model_tags ) == 0 :
112+ model_tags = response .xpath ('//table/tr' )
113+
107114 for model_tag in model_tags :
108- model_id = model_tag .xpath ('@href' )[0 ].re (r'spec/(\d+)/' )[0 ]
109- model_name = model_tag .xpath ('@title' )[0 ].extract ()
115+ model_id = model_tag .xpath ('td[@class="name_d"]/a/@href' )[0 ].re (r'spec/(\d+)/' )[0 ]
116+ model_name = model_tag .xpath ('td[@class="name_d"]/a/@title' )[0 ].extract ()
117+ price = model_tag .xpath ('td[@class="price_d"]/text()' ).re (ur'(\d+\.\d+)' )
110118
111119 model = ModelItem ()
112120 model ['id' ] = model_id
113121 model ['name' ] = model_name
114122 model ['series_id' ] = series_id
123+ model ['price' ] = price
115124 yield model
116125 count += 1
117126 log .msg ('[parse_selling] model count is %d' % count )
@@ -127,12 +136,14 @@ def parse_model_selled(self, response):
127136 model_id = model ['Id' ]
128137 model_name = model ['Name' ]
129138 group = model ['GroupName' ]
139+ price = model ['Price' ]
130140
131141 model = ModelItem ()
132142 model ['id' ] = model_id
133143 model ['name' ] = model_name
134144 model ['series_id' ] = series_id
135145 model ['group' ] = group
146+ model ['price' ] = price
136147 yield model
137148 count += 1
138149 log .msg ('[parse_selled] model count is %d' % count )
0 commit comments