Skip to content

Commit

Permalink
scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
jazzido committed Oct 29, 2016
1 parent 1ee4b1f commit 251face
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions gpbscraper/gpbscraper/spiders/compras_ws.py
Expand Up @@ -41,9 +41,9 @@ def getOCs(self, response):
root = xml.fromstring(response.body)

for cr in root[1][0].getchildren():
req = Request(OC_DETAIL_BASE_URL + urllib.urlencode({'Key':
self.key,
'Anio': self.anio,
req = Request(OC_DETAIL_BASE_URL + urllib.urlencode({'Key':
self.key,
'Anio': self.anio,
'OrdenCompra': cr.find('ORDENCOMPRA').text}),
callback=self.getOCDetalle)

Expand All @@ -54,11 +54,17 @@ def getOCs(self, response):
item['importe'] = cr.find('IMPORTE').text
item['proveedor'] = cr.find('PROVEEDOR').text
item['destino'] = cr.find('DEPENDENCIA').text

tipo, suministro, anio = re.search("(.+) (\d+)/(\d+)", cr.find('EXPEDIENTE').text).groups()
item['anio'] = anio
item['tipo'] = tipo
item['suministro'] = suministro

m = re.search("(.+) (\d+)/(\d+)", cr.find('EXPEDIENTE').text)
if m is not None:
tipo, suministro, anio = m.groups()
item['anio'] = anio
item['tipo'] = tipo
item['suministro'] = suministro
else:
item['anio'] = self.anio
item['tipo'] = ''
item['suministro'] = ''

item['compra_linea_items'] = []

Expand All @@ -68,7 +74,7 @@ def getOCs(self, response):


def getOCDetalle(self, response):

root = xml.fromstring(response.body)

orden_compra = response.request.meta['compra']
Expand Down

0 comments on commit 251face

Please sign in to comment.