Jump to content

need expert help with URL and HTML


gamb00ler

Recommended Posts

I wish to create a URL for a commercial site that supplies fixed data for a few data fields.

 

For instance the Mastercard Currency Conversion webpage:  https://www.mastercard.us/en-us/personal/get-support/convert-currency.html

 

I want to create a URL for that webpage that populates the four main fields (From, Amount, To and Bank Fee).

 

If things were simple I would just add "?From=United States&Amount=1000&To=Thailand&BankFee=0" to the URL for the page.

 

 

 

But of course the world is rarely so uncomplicated.

So far, I've tried using the field name given in the HTML source for Amount (txtTAmt) but appending ?txtTAmt=1000 to the URL just produces the standard web page with no data for Amount.

 

my URL looked like: www.mastercard.us/......../convert-currency.html?txtTAmt=1000

 

I found the field name by right clicking on the Amount field and then choosing Inspect in my Chrome browser.

 

What to try next?

 

The ultimate goal is to load that webpage at 3:10AM every weekday because that's the time that the daily conversion rate is set.

MacOS has a great tool for automating tasks like this, but for this page I need to supply the data.  The corresponding Visa rate and Wise pages "remember" the last data values so I don't need to populate the fields on their webpages.

 

 

 

 

 

 

 

Edited by gamb00ler
Link to comment
Share on other sites

4 minutes ago, simon43 said:

Read up on GET and POST methods of posting data to a web form.  You're trying a GET post, and you probably need to use Curl app and do a POST of your data.

I'm not developing a web page, I'm just accessing a web page that is used to initiate a query to the web publisher's database.  In this case it's MasterCards exchange rate database.  I'm just using a normal web browser to access their page.

Link to comment
Share on other sites

If JSON as a reply works for you then you can just hit up their API that is used by that form page behind the scenes. You can easily adjust the querystring parameters there:

 

https://www.mastercard.us/settlement/currencyrate/conversion-rate?fxDate=0000-00-00&transCurr=EUR&crdhldBillCurr=USD&bankFee=0&transAmt=1

 

Otherwise: you can't just fill their input fields with stuff you send in the URL if their page was not coded to behave that way. What you could also do is make a JS bookmarklet that will run some Javascript in the page to set the values.

  • Like 1
Link to comment
Share on other sites

@eisfeld, my last employment as a developer was 1994... LOL.  HTML was V1 and I was writing in C on OS/2 using token ring networking.  I switched to a much more fun career with no boss but probably somewhat less remuneration.

 

I had seen examples where the method I was trying did work, so I thought I would give it a shot.

 

Plus, now I've realized that MasterCard only changes their rate once a day so I can just manually get the rate at a more reasonable time rather than the moment they update their database.

 

Thanks for replying.  I'll see if I can figure out what your answer means ????.

Link to comment
Share on other sites

4 minutes ago, gamb00ler said:

@eisfeld, my last employment as a developer was 1994... LOL.  HTML was V1 and I was writing in C on OS/2 using token ring networking.  I switched to a much more fun career with no boss but probably somewhat less remuneration.

 

I had seen examples where the method I was trying did work, so I thought I would give it a shot.

 

Plus, now I've realized that MasterCard only changes their rate once a day so I can just manually get the rate at a more reasonable time rather than the moment they update their database.

 

Thanks for replying.  I'll see if I can figure out what your answer means ????.

What @eisfeld is saying is this:

 

The webpage you refer to is using what most call "WEB 2.0". in other words, it is not making a standard HTTP request and refreshing the page based on your inputs. Instead it is being driven by JavaScript that is making an AJAX ("Asynchronous Javascript and XML") call to get that data and inject it into the page dynamically.

 

Since the AJAX calls are, in the end, simply HTTP requests, like normal web page requests, you can still make that call like any normal page. If you use the URL @eisfeld provided, you will see a result returned in the JSON format:

 

REQUEST:

https://www.mastercard.us/settlement/currencyrate/conversion-rate?fxDate=0000-0000&transCurr=EUR&crdhldBillCurr=USD&bankFee=0&transAmt=1

 

RESPONSE:

{"name":"settlement-conversion-rate","description":"Settlement conversion rate and billing amount","date":"2022-03-11 14:41:45","data":{"conversionRate":1.1121182,"crdhldBillAmt":1.1121182,"fxDate":"2022-03-10","transCurr":"EUR","crdhldBillCurr":"USD","transAmt":1}}

This JSON data can be parsed easily with PHP or other languages. 

 

  • Like 2
Link to comment
Share on other sites

2 hours ago, gamb00ler said:

I'm not developing a web page, I'm just accessing a web page that is used to initiate a query to the web publisher's database.  In this case it's MasterCards exchange rate database.  I'm just using a normal web browser to access their page.

I know, but the query to that database will not work with a GET post.  It needs a POST format and parsing of the returned data.

Edited by simon43
  • Confused 1
Link to comment
Share on other sites

1 hour ago, simon43 said:

I know, but the query to that database will not work with a GET post.  It needs a POST format and parsing of the returned data.

There is no "GET post" in HTTP. It's either GET or POST (or any of the other HTTP methods). And in this case he can actually query the API just fine with the querystring parameters in a GET request as you can see when clicking the example link I posted. You can easily observe the GET request that is done by the JS in that page to the backend in your browsers dev tools network tab.

  • Like 1
Link to comment
Share on other sites

both GET and POST do work, but GET works over the URL, which is limited to 2^11 characters.

that's why more voluminous data (such as images, files, blobs) needs POST.

 

OP, things have changed since 1994. Variables transmitted by GET requests are no longer automatically globals.

You will need to write a simple script, for example in PHP, to read the variables from the URL and use them.

And think about validation, because that's a way to get haxxor'd

 

https://www.w3schools.com/php/php_forms.asp

 

EDIT: sorry I misunderstood the OP.

 

What this post says is useful:

 

And then write a script, for example in PHP, to parse the JSON response:

https://code.tutsplus.com/tutorials/how-to-parse-json-in-php--cms-36994

 

 

Edited by tgw
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.







×
×
  • Create New...