Reputation: 384
I want to crawl the site https://www.ups.com/de/de/shipping/surcharges/fuel-surcharges.page. There, the company is giving all fuel surcharges they are adding to invoice amounts. I need the information to correctly calculate some costs. Unfortunately, UPS is currently not willing to send me the data in a readable format on a regular basis. Thus, I thought about crawling the website and getting the information by myself.
Unfortunately, when using postman or my crawling tool rcrawler, the GET request to the site hides the data tables. How could I trick the site to return all the data as it does when using chrome browser?
For example, the standard tier costs table looks like this in postman (containing just the headlines of the columns but no values):
<div class="ups-contentBlock_wrap clearfix">
<p>Der Standard Service Treibstoffzuschlag gilt für
alle UPS Standard Sendungen. Die Änderungen des
auf den nächsten Cent gerundeten Zuschlages
werden am Montag jeder Woche wirksam und basieren
auf den von der Generaldirektion der
Europäischen Kommission (ECDG) festgesetzten
Verbraucherpreisen für Dieselkraftstoffe,
einschliesslich der Zölle und Steuern zweier
Vorwochen. Der Zuschlag für die Woche vom 6.
Februar 2017 basiert auf dem Dieselkraftstoffpreis
für die Woche vom 23. Januar 2017.
Wöchentliche Aktualisierungen werden von der
Generaldirektion Energie der Europäischen
Kommission (ECDG) für Energie und Verkehr im
Ölbericht veröffentlicht.</p>
<p>Der Treibstoffzuschlag für den UPS
Standard-Service basiert auf den Angaben in der
folgenden Tabelle:</p>
<div class="ups-table fuel-surcharge">
<table id="DieselFuelPriceStandardFuelSurcharge">
<thead>
<tr>
<th colspan="3">Dieseltreibstoffpreis
(EUR pro 1.000 Liter)</th>
</tr>
</thead>
<tbody>
<tr>
<th>
<p>Mindestens</p>
</th>
<th>
<p>Aber weniger als</p>
</th>
<th>
<p>Zuschlag</p>
</th>
</tr>
</tbody>
</table>
</div>
</div>
<div class="ups-contentBlock_wrap clearfix">
<p>Die Höhe des Treibstoffzuschlags kann sich ohne
vorhergehende Ankündigung ändern. Wenn der
Treibstoffzuschlag über 14,50% ansteigt oder es
zu Änderungen der Grenzwerte kommt, wird die
obenstehende Übersicht aktualisiert. Ungeachtet
der durch die ECDG genannten durchschnittlichen
Treibstoffpreise oder der obenstehenden
Übersicht werden die aktuellen oben
veröffentlichen prozentualen Anteile des
Treibstoffzuschlages für die festgelegten
Zeiträume berücksichtigt.</p>
</div>
Comparing this with the browser result shows the problem.
Upvotes: 0
Views: 490
Reputation: 10329
You are just naively downloading the website source.
If you open developer tools in your browser (usually F12) and open the Network tab, and reload the page, you will see all the requests that are made.
You will notice several javascript files, and somewhere in that list you will also see a file named de.json
. If you look at the response form that request, you will see all the rates displayed as json.
One of the javascript files parses this and displays this data in a table, in your browser. Postman does not have a javascript interpreter; actually it does, but it is not used same as a web browser. So requesting the entire page will not show you this data.
However, if you GET https://www.ups.com/assets/resources/fuel-surcharge/de.json you will get the data you are after.
Upvotes: 2