0
Is it possible to break a line from a specific section of Json, transform it into an array, and then streamline it? Why do I ask this.. I am developing a file mining bot and came across a situation where some pages return only one file on this line and other pages on the same site may contain multiple information, so that my request is valid and I can extract the pdf, I need to make that division when there is such a case.
Excerpt from the code: Url tested: http://www.bcb.gov.br/pre/normativos/busca/normativo.asp?tipo=Circ&ano=2009&numero=003467
def parseHTML_JS(self, response):
idBuscaAnexo = json.loads(response.body)['d']['results'][0]['ID']
contente = json.loads(response.body)['d']['results'][0]['Texto']
data = json.loads(response.body)['d']['results'][0]['Data1']
categorias = response.meta['Categoria']
descricao = response.meta['Description']
titulo = response.meta['Titulo']
pdfs = json.loads(response.body)['d']['results'][0]['DocumentosAnexados'][0:][:-5]
url_pdfs = "http://www.bcb.gov.br/pre/normativos/busca/downloadNormativo.asp?arquivo=/Lists/Normativos/Attachments/"+str(idBuscaAnexo)+"/"+str(pdfs)
req = Request(url=url_pdfs, callback=self.parsePdf)
req.meta['Categoria'] = categorias
req.meta['Description'] = descricao
req.meta['Titulo'] = titulo
req.meta['Content'] = contente
req.meta['Data'] = data
yield req
It is not clear what you need to do. In the second case, that more than one file arrives, you want to return the name of all of them or just one?
– Woss
need return the following return, for example: position 0: u'Circ_3467_v1_o.pdf', position 1: u'Circ_3467_v2_l.pdf', position 2: u'Circ_3467_v2_p.pdf'
– Jonathan Igor Bockorny Pereira
I was able to make a return that brings me an array, but it still contains the "Trash" that would be those numbers next to #, I can isolate # ; but I don’t know how to get the numbers out
– Jonathan Igor Bockorny Pereira
if you have where I can show the whole code, tell me I’ll show you the whole code
– Jonathan Igor Bockorny Pereira
Have the question itself, just [Edit] and add the code.
– Woss
Stackoverflow does not accept very large codes
– Jonathan Igor Bockorny Pereira
Then elaborate a [mcve]
– Woss