Well, I need to get the HTML of a LATAM airline page. By specifying best, the page where I need to get the HTML is the reservation page of your ticket. The link corresponds to this:
https://www.latam.com/pt_br/apps/personas/mybookings#reservas?recordLocator= _ YOUR RESERVATION CODE _ &lastName= YOUR LAST NAME
So when I come in with a valid link I have something like this:
https://www.latam.com/pt_br/apps/personas/mybookings#reservas?recordLocator=AZXFAS&lastName=SILVA
* I can not pass a valid link because of customer safety
If I paste the valid link in my browser, it loads the page, then loads a little more and shows me my trip date, if I want to change something on the trip, if I want to choose my seats and so on.
What I need to do :
I have spreadsheets with more than 2000 reservations, I just need to check if my spreadsheet reservation is valid or not. Soon I thought: Easy! A network.request to take reservation by reservation and in valid link cases there will be some more information that I will receive in my network.request, so I would do a simple check using the string.find inside the event.response and I would know soon if the reservation is valid or not.
Code:
local function networkListener( event ) if ( event.isError ) then print( "Network error: ", event.response ) else local ans = event.response print ( event.response ) print(" ") print(" ") print( string.find( ans, "data-dtconfig", 1) ) end end local url = "https://www.latam.com/pt\_br/apps/personas/mybookings#reservas?recordLocator=zzzzz&lastName=SILVA" network.request(url, "GET", networkListener )
Problem I found:
Well, regardless if I put a valid link or not, the network request ALWAYS returns error (404) on the page, as if it was not found. And you know what’s weird? If I use WebView it loads the right page.
That is, I am missing something in network.request … Does anyone know me explain what I am doing wrong?
Console response when trying to connect with a valid link:
23:54:05.107 <!DOCTYPE html>
23:54:05.107 <!-- Main header files -->
23:54:05.107 <head>
23:54:05.107 <meta charset=“utf-8”>
23:54:05.107 <meta http-equiv=“X-UA-Compatible” content=“IE=edge”>
23:54:05.107 <title>No encontramos la página | LATAM Airlines</title>
23:54:05.107 <meta name=“viewport” content=“width=device-width, user-scalable=no, initial-scale=1.0”>
23:54:05.107 <meta name=“description” content="">
23:54:05.107
23:54:05.107 <meta property=“og:title” content=“Error 404 LATAM”/>
23:54:05.107 <meta property=“og:image” content="http://upload.wikimedia.org/wikipedia/commons/c/ca/1x1.png"/>
23:54:05.107 <meta property=“og:description” content=""/>
23:54:05.107
23:54:05.107 <!-- Site CSS -->
23:54:05.107 <link rel=“stylesheet” href="https://s.latamstatic.com/layout/ui/3/css/bootstrap.min.css">
23:54:05.107 <link rel=“stylesheet” href="https://s.latamstatic.com/layout/ui/3/css/global.min.css">
23:54:05.107 <link rel=“stylesheet” href="https://s.latamstatic.com/layout/ui/3/css/latam-mu.min.css">
23:54:05.107 <link rel=“stylesheet” href="/assets/ns/css/main-latam-error-pages.css">
23:54:05.107 </head>
23:54:05.107
23:54:05.107 <body>
23:54:05.107
23:54:05.107 <!-- Google Tag Manager (noscript) -->
23:54:05.107 <noscript><iframe src=“https://www.googletagmanager.com/ns.html?id=GTM-RPVH” height=“0” width=“0” style=“display:none; visibility:hidden”></iframe></noscript>
23:54:05.107 <!-- End Google Tag Manager (noscript) -->
23:54:05.107
23:54:05.107 <main class=“ErrorPages” role=“main” data-url-src="/assets/ns/data/routes.json" data-error=“404”>
23:54:05.107 <section class=“l-section”>
23:54:05.107 <div class=“container”>
23:54:05.107 <div class=“ErrorPages-content”>
23:54:05.107 <!-- Mobile only component–>
23:54:05.107 <div class=“ErrorPages-errorType visible-xs”>
23:54:05.107 <div class=“ErrorPages-errorText”>
23:54:05.107 <h2>Error</h2>
23:54:05.107 </div>
23:54:05.107 <div class=“ErrorPages-errorNumber”>
23:54:05.107 <h2>404</h2>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 <!-- Mobile only component–>
23:54:05.107 <div class=“row”>
23:54:05.107 <div class=“col-md-6 col-sm-7 col-xs-12”>
23:54:05.107 <div class=“row”>
23:54:05.107 <div class=“col-md-11 pull-right”>
23:54:05.107 <div class=“ErrorPages-infoCard”>
23:54:05.107 <div class=“ErrorPages-logoCard”>
23:54:05.107 <img src="/assets/ns/images/content-image/header/logo_latam_color.svg" alt=“LATAM Airlines”/>
23:54:05.107 </div>
23:54:05.107 <div class=“ErrorPages-infoText”>
23:54:05.107 <h2 role=“heading” aria-level=“1”>No encontramos la página</h2>
23:54:05.107 <div class=“richtext”>
23:54:05.107 <p>Es posible que la página que buscas ya no exista o que haya cambiado su nombre.</p>
23:54:05.107 <p>Te invitamos a continuar tu navegación desde nuestra página de inicio.</p>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 <div class=“ErrorPages-callToAction”>
23:54:05.107 <div class=“ErrorPages-buttonAction”>
23:54:05.107 <a href=“http://www.latam.com/” class=“btn-flat first-level flat-large”>
23:54:05.107 <span class=“Btn-textBox”>
23:54:05.107 <span class=“Btn-text”>Ir al home</span>
23:54:05.107 </span>
23:54:05.107 </a>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 <div class=“col-md-6 hidden-xs”>
23:54:05.107 <div class=“row”>
23:54:05.107 <div class=“col-md-11 pull-left”>
23:54:05.107 <div class=“ErrorPages-errorType”>
23:54:05.107 <div class=“ErrorPages-errorText”>
23:54:05.107 <h2>Error</h2>
23:54:05.107 </div>
23:54:05.107 <div class=“ErrorPages-errorNumber”>
23:54:05.107 <h2>404</h2>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 </div>
23:54:05.107 <div class=“ErrorPages-destination”></div>
23:54:05.107
23:54:05.107 </div>
23:54:05.107 </section>
23:54:05.107 </main>
23:54:05.107 <!-- jQuery -->
23:54:05.107 <script src=“https://code.jquery.com/jquery-1.11.1.min.js” type=“text/javascript”></script>
23:54:05.107 <!-- Cookies Utils -->
23:54:05.107 <script src="/scripts/ns/cookiesUtils.js" type=“text/javascript”></script>
23:54:05.107 <!-- Site JS -->
23:54:05.107 <script src="/scripts/ns/error-page.js" type=“text/javascript”></script>
23:54:05.107
23:54:05.107 </body>
23:54:05.107 </html>
Note: As it now stands, a valid link and an invalid link is not making any difference to the event.response because the network.request is not working correctly