Buy cheaper plane tickets using a VPN: truth or myth?
Excerpt
Is it true that airlines, for the same flight, make different prices depending on the country derived by your IP address when purchasing? or it is only a myth?
July is the Smartproxy month on The Web Scraping Club. For the whole month, following this link, you can use the discount code SPECIALCLUB and get a massive 50% off on any proxy and scraper subscription.
[

The summer holiday season started and, on Tik Tok, Youtube, and other media, just like every year, there’s an article or a video regarding tricks on how to save money when booking a flight.
Common sense apart, like booking earlier and trying different days to see what’s the cheapest combination of dates, there’s always a travel guru saying “I’ve discovered trick airlines don’t want you to know! Using a VPN and cleaning your cookies every time (just to give all this nonsense a hacker-ish appearance), you can simulate connecting by different countries and get a better ticket price! Oh yes, and here’s my affiliate link for VPN X, Y, and Z”
Nothing against the content creator in particular, and as you can see I use affiliate links too, for services that can be useful for the community and they are usually matched with a discount code, so it’s a win-win for everyone.
I’ve heard this trick for years and for sure also airlines did it too. Maybe years ago this worked, but it was a glitch solved as soon as it was exploited. But we can use this experiment to exercise with Playwright and the usage of proxies in it.
Checking ticket prices with Playwright and proxies
As usual, the code is available on the GitHub repository available to paying readers. If you’re one of them but don’t have access, please write me at pier@thewebscraping.club. I manually need to enable the accesses and I need to know your GitHub username.
We’ll check the prices on the website of British Airways, which is protected by Akamai, using Playwright and integrating residential proxies from Smartproxy.
I want to check all the flights from London to New York available for the 12th of August.
This implies several interactions with the website’s UX, selecting dates and airports, and a simple Scrapy spider it’s not enough.
[

We’re not interested in downloading data but only having a look at it, just to check if the prices change from country to country of connection.
First run, no proxy
As a first run, I’ll use Brave Browser with Playwright and, as I’m running the script from Italy, I’ve been redirected to the Italian version of the website.
Technically, after clicking for agreeing on cookie collection, we can access the website and type in the form the departure airport, and the destination and select the date.
We’re using the page.type function to write data in the form, while page.click with XPath selectors for the navigation of the website.
[

As a result, we see that all the prices are 2.092 pounds for the economy class.
[

Let’s see if something changes if we add a proxy and connect from the USA.
Second run, connecting from the USA
In this case, I’ve added the proxy configuration in the browser call, and, depending on the input country of the script, I connect to a different endpoint of the Smartproxy residential proxies.
[

But the result is the same as before, with the same price for the same flights.
Let’s try connecting from the United Kingdom, the home country of the company.
Third run, connecting from the GBR
Added a new country in our proxy setup, the result is the same.
[

Again the same prices as the previous runs, so we can say that our job as a debunker finished here.
A real use case for proxies
Jokes apart, there are many cases, from social media scraping to online advertising monitoring which needs a proxy solution where it’s possible to choose the country of the IP.
Avoiding the geofencing
Geofencing is a location-based marketing practice widely used in the e-commerce industry to target customers based on their geographic location. It involves creating virtual boundaries or “geofences” around specific physical locations, such as retail stores, shopping centers, or even entire cities. When a user accesses an e-commerce website, the website can retrieve the user’s IP address, which provides information about the user’s internet connection and, in some cases, their general geographic location.
Once the e-commerce company has access to the user’s location information, it can offer various location-based services. For example:
a. Personalized Recommendations: By knowing the user’s location, the e-commerce platform can offer product recommendations tailored to local preferences or nearby events.
b. Localized Pricing and Inventory: Geolocation enables businesses to display prices and available inventory specific to the user’s region, considering factors like shipping costs and availability.
c. Store Locator: E-commerce companies can provide users with a store locator feature to find nearby physical retail locations for in-store purchases.
d. Targeted Marketing: Location data allows e-commerce businesses to send targeted marketing campaigns to users based on their current or past locations, offering promotions or discounts relevant to their surroundings.
It can also happen that one e-commerce is not available in some countries while it’s in others. In my experience, I’ve seen several cases and in most of these cases, even if I don’t understand completely the business reasons behind this decision. One of this e-commerce is italist.com, which is not available in Italy
[

but from the USA or any other country, it is.
[

Final remarks
In this episode of The Lab, we’ve seen how to integrate proxies in a simple Playwright program, but also the importance of using them in some circumstances, like e-commerce monitoring in case of geofencing.