Modal ajax mail tracking

Asked

Viewed 4,315 times

0

Is it possible to make a script that pulls the tracking of some item on the post office page? For example, inside my website: https://meusite.com.br/requests. There’s the link in the case for tracking PO117284423BR

It would have to create a modal that when the link "PO117284423BR" is clicked it open with this: inserir a descrição da imagem aqui

Or something like that. Is it possible? Or with the post office website?

  • 1

    The WS documentation of the post office is https://www.correios.com.br/para-voce/correios-de-a-a-z/pdf/traceobjects/manual_tracking objectsws.pdf

  • Use http://linktrack.mooo.com/ or simply make http://linktrack.mooo.com/RX704890085CN/html. It’s very fast.

2 answers

3


Unfortunately, you will not be able to use the post office website directly.

You will need to develop an application, which using the post office API (manual posted by Felipe), make a request to the post office website and return with the tracking information, and then you can assemble a page to display the result.

From what I read on page 11 of the manual, you will need to request a user and password in order to use the WS of the mail and make this request.

An alternative would be to use another site that does all this work for you. I found this one: http://www.linkcorreios.com.br

It seems that just add the tracking code to the end of the URL and ready: http://www.linkcorreios.com.br/? id=PO117284423BR

You can put this link on your site, and make it open in a modal or another window.

  • For example, can you open with Ajax, only such DIV? Without pulling everything.

  • Just via JS is not possible as it is a browser security restriction that you cannot handle the HTML of another domain.

  • What you could do is request this URL on the server, using some programming language like PHP for example, and then interpret the response and extract only the information you want.

0

The following HTML code gets this tracking data:

<html>
<body onload="document.aux.submit()">

 <form name="aux" method="POST" action="https://www2.correios.com.br/sistemas/rastreamento/resultado_semcontent.cfm">
  <input name="Objetos" value="PO117284423BR">
 </form>

</body>
</html>

A tip:

If you want to view tracking data quickly on the terminal, use the curl to send the request to the post office page, and a text browser to view the status of the order, such as html2text, elinks, lynx or w3m. For example, using the bash at the terminal of Ubuntu:

sudo apt install html2text
curl -sS -X POST -d Objetos=PO117284423BR https://www2.correios.com.br/sistemas/rastreamento/resultado_semcontent.cfm | html2text

or

sudo apt install elinks 
curl -sS -X POST -d Objetos=PO117284423BR https://www2.correios.com.br/sistemas/rastreamento/resultado_semcontent.cfm | elinks -dump -dump-color-mode 1

or

sudo apt install lynx    
curl -sS -X POST -d Objetos=PO117284423BR https://www2.correios.com.br/sistemas/rastreamento/resultado_semcontent.cfm | lynx --stdin --dump

or

sudo apt install w3m    
curl -sS -X POST -d Objetos=PO117284423BR https://www2.correios.com.br/sistemas/rastreamento/resultado_semcontent.cfm | w3m -dump -T text/html

Browser other questions tagged

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