How to get paramater for payload POST (1 Viewer)

ongke0711

New member
Local time
Today, 18:01
Joined
Feb 20, 2020
Messages
4
Hi All,

I am amateur in the web development. I just need to get data from a website through its API and use Python (or HTTP Request in VBA) to do this.
This is link of website: ( I cannot paste the link to this post)
The payload has parameters as picture below: when you type "031.." on the "Search textbox"

Screen Shot 2023-05-23 at 14.07.18.png


In the Payload, parameter "h" is changed every time the page refresh/ reload. I don't know how to get the value of "h" from this website to provide for "Form Data" on the code Python.
Could any one help me to get this value. Thank you very much.
 

cheekybuddha

AWF VIP
Local time
Today, 12:01
Joined
Jul 21, 2014
Messages
2,280
This site really struggles to load for me in the UK.

However, I did manage to find a couple of functions where the h parameter appears to be hardcoded:
JavaScript:
function LoadDoanhNghiepHD() {
    $.ajax({
        type: "POST",
        url: "/_layouts/15/NCS.Control.QTDKDN/Ajax/SorlSearchEnterpriseName.ashx",
        data: { searchField: $("#ctl00_ctl35_txtSearchTerm_entHD").val(), h: "638204568110353956-55F674376BDFC152B30B28E9482FB3B02AC1FF12BD88F00EF7388ED0573691FA", lang: 'en' },
        dataType: "html",
        success: function (data) {
            if (data == "RELOAD") {
                var agree = confirm('The session ends, please reload the page to continue!');
                if (agree) location.reload();
            }
            var lstChucVu = eval(data);
            //Xoa du lieu cu
            $("#lstDoanhNghiepHD ul").remove();

            $("<ul/>").appendTo($("#lstDoanhNghiepHD"));
            for (var i = 0; i < lstChucVu.length; i++) {
                var vDNId = lstChucVu[i].Id;
                $("<li/>", { id: 'li_chucvuHD_' + i.toString(), DNId: lstChucVu[i].Id, html: lstChucVu[i].Name }).appendTo("#lstDoanhNghiepHD ul");
                if (i % 2 == 0) {
                    $("#li_chucvuHD_" + i.toString()).addClass("item");
                }
                else {
                    $("#li_chucvuHD_" + i.toString()).addClass("alteritem");
                }
                $("#li_chucvuHD_" + i.toString()).click(function (event) {
                    $("#ctl00_ctl35_txtSearchTerm_entHD").val(vDNId);
                    $("#ctl00_ctl35_cmdSearchDN").click();
                    return false;
                });
            }
            $("#lstDoanhNghiepHD").show('slow');
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var agree = confirm('The session ends, please reload the page to continue!');
            if (agree) {
                location.reload();
            } else {

            }
        }
    });
};
and
JavaScript:
// search HTX
function LoadHTX() {
    $.ajax({
        type: "POST",
        url: "/_layouts/15/NCS.Control.QTDKDN/Ajax/SorlSearchCooperatives.ashx",
        data: { searchField: $("#ctl00_ctl35_txtSearchTerm_HTX").val(), h: "638204568110353956-55F674376BDFC152B30B28E9482FB3B02AC1FF12BD88F00EF7388ED0573691FA", lang: 'vn' },
        dataType: "html",
        success: function (data) {
            if (data == "RELOAD") {
                var agree = confirm('The session ends, please reload the page to continue!');
                if (agree) location.reload();
            }
            var lstChucVu = eval(data);
            //Xoa du lieu cu
            $("#lstHTX ul").remove();

            $("<ul/>").appendTo($("#lstHTX"));
            for (var i = 0; i < lstChucVu.length; i++) {
                var vDNId = lstChucVu[i].Name;

                if (i == 0) $("#ctl00_ctl35_txtSearchTerm_HTX_id").val(lstChucVu[i].Id);

                $("<li/>", { id: 'li_chucvuHTX_' + i.toString(), DNId: lstChucVu[i].Id, html: lstChucVu[i].Name }).appendTo("#lstHTX ul");
                if (i % 2 == 0) {
                    $("#li_chucvuHTX_" + i.toString()).addClass("item");
                }
                else {
                    $("#li_chucvuHTX_" + i.toString()).addClass("alteritem");
                }
                $("#li_chucvuHTX_" + i.toString()).click(function (event) {
                   
                   
                    $("#ctl00_ctl35_txtSearchTerm_HTX_id").val($(this).attr('dnid'));
                    $("#ctl00_ctl35_cmdSearchHTX").click();
                    return false;
                });
            }
            $("#lstHTX").show('slow');
        },
        error: function (xhr, ajaxOptions, thrownError) {
            var agree = confirm('The session ends, please reload the page to continue!');
            if (agree) {
                location.reload();
            } else {

            }
        }
    });
};

Since it took over 20 minutes for this page to load for me ( o_O ), I haven't tried refreshing to see if the value changes!

If it does change on every reload, then you will probably have to scrape the page source to find the value within the javascript function, as it's probably generated by the server.
 
Last edited:

ongke0711

New member
Local time
Today, 18:01
Joined
Feb 20, 2020
Messages
4
This site really struggles to load for me in the UK.

However, I did manage to find a couple of functions where the h parameter appears to be hardcoded:

...
Since it took over 20 minutes for this page to load for me ( o_O ), I haven't tried refreshing to see if the value changes!

If it does change on every reload, then you will probably have to scrape the page source to find the value within the javascript function, as it's probably generated by the server.

Thank you very much for your help and your spending much time for the website from my country. I will try to explore more from 2 these functions to solve my case.
 

cheekybuddha

AWF VIP
Local time
Today, 12:01
Joined
Jul 21, 2014
Messages
2,280
This is the line that you need to find:
JavaScript:
// ...
data: { searchField: $("#ctl00_ctl35_txtSearchTerm_HTX").val(), h: "638204568110353956-55F674376BDFC152B30B28E9482FB3B02AC1FF12BD88F00EF7388ED0573691FA", lang: 'vn' },
// ...
You probably don't need to worry about the function if you want to make the POST request separately (eg via CURL or Postman) - it's just a JQuery ajax() call
 

Users who are viewing this thread

Top Bottom