Exemplo n.º 1
0
 def parse(self,response):
     xxs = XmlXPathSelector(response)
     citys = xxs.select('//division')
     list = []
     for city in citys:
         list.append((
                 city.select('id/text()').extract()[0],
                 city.select('name/text()').extract()[0],
                 city.select('location/latitude/text()').extract()[0],
                 city.select('location/latitude/text()').extract()[0]
             ))
     sql = 'insert into city_meituan (m_id,`name`,latitude,longtitude)value(%s,%s,%s,%s)'
     trun = 'truncate table city_meituan'
     db.batchSQL(sql=sql,list=list,trun=trun)