How to make a scrapy post in python?

Asked

Viewed 19 times

-2

I am learning the lib Scrapy in Python and I am having difficulty to perform a request with the POST method for the url. I’m trying to use the following code:

form={"letraLocalidade":"",
"ufaux":"",
"pagina": "/app/faixa_cep_uf_localidade/index.php",
"mensagem_alerta": "",
"uf": "SC",
"localidade":"",
"cepaux":""}

scrapy.Request(
          'https://buscacepinter.correios.com.br/app/faixa_cep_uf_localidade/carrega-faixa-cep-uf-localidade.php',
           method='POST',
           body=json.dumps(form),
           headers={'Content-type':'application/json; charset=utf-8'}
)

I have performed a similar test for another page of the Post Office, but with the lib selenium and bs4 and I wanted to repeat that same test but with the lib scrapy.

The goal is to catch all ZIP bands of a given municipality through a UF. For example SC has 295 municipalities with 321 CEP bands (Some municipalities have specific ranges for urban areas).

Two observation points I need to make:

1- Create a post with scrapy

2- Navigate between 'next' pages to capture all Ufs

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.