network.request does not respond correctly?

My project is just this code so far, I’ve literally done nothing else, config.lua is the default that already comes, the main.lua is this code with the network.request hahahaha

@CoronaChris

Thankss !! But, I discovered that without #Reservas does not work!

The #reserves that makes me redirect directly to the reserve page purchased, if I do not use it the corona redirects only to the site to put the information … Does anyone have any suggestions?

Other information as well. If I use the POST method without the reservations I believe it would work, but I have a problem with it. If I get a same link, and put the POST method and update the corona several times, the return changes practically every time, ie, the same link is returning me different codes … I think it’s because network.request is not expecting the page to load completely (because after you enter the page of a reservation already purchased, it loads a bit of JS code and then shows me all the information, I do not think the network .request is waiting for the JS to load … Anyone in any solution?

edit: 

To put it simply: The POST method is not delivering the two variables at the following link: https://www.latam.com/pt_br/apps/personas/mybookings? the variables that would be “reserve” and “last name” (recordLocator and lastName)

Correcting:

The POST method delivers the variable but only when it wants, it’s as if it tries to deliver before the site is ready to receive, I can not explain very well what’s happening, but it’s simply this, if I keep refreshing the simulator, some Sometimes it can return me a valid link and most of the time it returns invalid.

In your end-user case, how often can the user request that URL? I’m pretty sure the service isn’t expecting the same user to hit the URL over and over repeatedly. 

We have a saying around here, “Help us help you”. The reason we ask for a .zip file is it takes time to try and reproduce the files. You have them handy. It’s way faster for you to make a .zip file than it is for us to create a project for you and drop your code into it.

Rob

@Rob

Well, it’s like I said at the beginning of the topic, I have a spreadsheet with more than 2000 reservations and last names to be defined as “valid” or “invalid”. so I would have to test those 2000 combinations at once (I would not mind if it took 1 hour or more, I just need those combinations tested)

I WOULD LIKE to be able to make a valid reservation and surname valid for you to test, but the privacy policy prevents me from doing this, because even when you have a valid reservation, you could change the tickets, the data and even make a purchase for people, then this data is quite restricted, so I always try to post as much detail here.

But did you get the idea? It is a spreadsheet of more than 2000 reservation codes and last name, and I have to simply say if that code is still valid or not. (All bookings were already valid one day, so I have to “update” the company database by verifying this)

Note:

My final intention, after making sure that the network.request is actually returning a true result, is to do a compile for windows with a two text box so that I can personally insert all the backup codes and all the last names at once , then I will store in two arrays and do the verification. But what I am having problems is actually the network.request

 

Link of the project I’m using > http://www.mediafire.com/file/26m92c78l692b8u/PlanilhaBabi.rar/file

You can ask any kind of thing! If I need prints, I’ll give them too.

Have you spoken to someone from LATAM about this? Are they going to be okay with you scraping their reservation site?

The file you posted seems to be based on POST and doesn’t appear to be returning anything.

Rob

most, if not all, endpoints will throttle on IP.  so if you are server requesting this info then well then you’ve got firewall issues.

But it’s because it’s not making sense to me. Rob, it’s POST but I tried GET too with #reservations and GET does not work, and if I get and put the same link in my browser I can get the HTML so I think it’s not too complex, doing it the wrong way, right?

If you can access a page with the key-value pairs being part of the URL, that should be a GET based script. The # starts a fragment identifier which is typically a client-side feature that can be used as an in-page anchor, fed to JavaScript for further processing on the client side or used by analytics tools that look at the whole URL and use key-value pairs after the # to indicate where the URL was clicked on. Let’s look at each of these:

as an anchor: There must be an anchor tag on the page like <a href="#sectiontojumpto"> in the page. The browser will use the text after the # and jump to that part of the page. Likewise someone could click on a URL in the page and also jump there. I doubt this is what LATAM is doing.

as additional information to JavaScript: In this case, JavaScript reads the part after the # and processes the key-value pairs which could lead to additional content being brought in by an AJAX style call. I suspect that this is what LATAM is doing.

for analytics. Some people will put tags after the # to identify the place where the URL is used. Lets say you want to share a news story to the web. You might do:

https://somenewssite.com/path-to-article.html#source=twitter

https://somenewssite.com/path-to-article.html#source=facebook

https://somenewssite.com/path-to-article.html#source=newsletter

https://somenewssite.com/path-to-article.html#source=website

Then using various tools that can analyze logs can now count how many hits to the article came from Twitter, from Facebook, etc. I doubt this is what LATAM is using…

Since I suspect the page is using page fragments in the 2nd form, the HTML would need to be downloaded to the browser which will execute JavaScript that is bringing additional content into the page. Corona’s network.request() will not execute the in-page javascript which means any content injected into the page simply won’t work. It just fetches the raw HTML for the primary request. 

You can see: https://stackoverflow.com/questions/7909969/what-is-the-symbol-in-the-url for more information about the use of the # mark.

I think the answer, which you’re probably not going to like is you’re not going to be able to do this with network.request(). There may be some weird hack-around using native.newWebView() (which won’t be very performant, if you can get it to work at all). I also suspect that LATAM doesn’t want you doing this in the first place. They, however, may have an API that other travel services can access to get information about a given reservation and would prefer you to access their reservation system in a manner they designed for that.

Rob 

First of all I would like to thank you for the complete response @Rob.

It makes sense in my head now, I understand that Latam protected herself against it, and even if it’s just you speculating, it made sense in my head.

So what I really have left is to use mouse macro to be able to copy the values ​​from the spreadsheet to the site values ​​of the latam (zZZZZzzzZz).

This takes hours, so I said I would not mind if the network.request took more than 1 hour.

Maybe loading in webView and using find is not a bad option, but I think it should take a little good … Yeah, I do not think there’s going to be a way :frowning:

Thanks again for the incredible help :wink: