Quantcast
Channel: Active questions tagged javascript - Stack Overflow
Viewing all articles
Browse latest Browse all 140762

Why are my search results not showing what i requested?

$
0
0

I am trying to submit a search form onto a website using Jsoup, then retrieve the particular resullts.

here is the site with which i am workin on https://eservices.cipc.co.za/Search.aspx

public class doAsync extends AsyncTask {

    View mview;
    Document searchResults;

    @Override
    protected void onPreExecute() {
        super.onPreExecute();
    }

    @Override
    protected Void doInBackground(String... strings) {


        String url="https://eservices.cipc.co.za/Search.aspx";

        try {
            //Connect to a website
            Connection.Response response = Jsoup.connect(url)
                    .timeout(20000)
                    .method(Connection.Method.GET)
                    .execute();

            //Find the form
            Document responseDocument = response.parse();
            Element potentialForm = responseDocument.select("form#aspnetForm").first();
            checkElement("form Element",potentialForm);
            FormElement form = (FormElement) potentialForm;



            //Fill the form and submit it
            Element ListSearchType = form.select("[name$=ctl00$cntMain$drpSearchOptions]").first();
            checkElement("Search type list",ListSearchType);
            ListSearchType.attr("dropdownSearch","dropdownSearch");



            //Name search
            Element txtBxNameSearch =form.select("[name$=ctl00$cntMain$txtSearchCIPC]").first();
            checkElement("name search txt box",txtBxNameSearch);
            txtBxNameSearch.val("K2019");



            //Submit the form
            searchResults = form.submit().cookies(response.cookies()).post();


            //Extract results
           searchResults.select("table[id$=ctl00_cntMain_gdvNames] > tbody > tr > td");


               System.out.println(searchResults.text());


        } catch (IOException e) {
            e.printStackTrace();
        }


        return null;
    }

    @Override
    protected void onPostExecute(Void aVoid) {
        super.onPostExecute(aVoid);


        AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
        mview = getLayoutInflater().inflate(R.layout.results, null);
        TextView tvView = mview.findViewById(R.id.txtV);
        Button btn2 = mview.findViewById(R.id.btnSend);

        tvView.setText(searchResults.text());

        btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {


            }
        });
        alert.setView(mview);
        AlertDialog dialog = alert.create();
        dialog.show();
    }
}
public static void checkElement(String name, Element element)
{
    if(element == null)
    {
        throw new RuntimeException("unable to find "+name);
    }
} 

My code does not return what i requested, instead it returns this.

////////// Welcome GUEST PLEASE LOG IN TO START TRANSACTING CUSTOMER LOGIN PASSWORD RESET CUSTOMER REGISTRATION ENTERPRISE SEARCH search for enterprises on our register using enterprise name, enterprise number or director ID/passport number CONTINUE TO SEARCH HOW-TO VIDEOS watch our how-to videos to guide you in filing transactions or retrieving documents WATCH VIDEOS SOCIAL MEDIA follow us on social media to interact with us and to get the latest updates SUPPORTED BROWSERS You are here: CIPC eServices » Home » Transact CIPC eServices System Welcome to the CIPC eServices system. To transact on this system you must have a valid CIPC customer code. Please note that currently you can only register private and non-profit companies with standard memorandum of incorporation, all other company types must be filed manually. Forms are available on http://www.cipc.co.za/ Customer Registration & Login Click on "CUSTOMER REGISTRATION" Indicate whether you are South African or not Type in ID or passport number Fill in all required fields on the registration form Set new password Login using customer code and password Security code and password are case sensitive Password Reset Click on "PASSWORD RESET" Type in customer code OTP is sent to cellphone number Once OTP confirmed, set new password OR Follow instructions on this page Services Offered COMPANY REGISTRATION private and non-profit company registration DIRECTOR AMENDMENTS amend company directors ANNUAL RETURNS file company and close corporation annual returns NAME RESERVATIONS reserve a name for company registration MEMBER AMENDMENTS amend close corporation members AUDITOR CHANGES appoint / resign auditors NAME CHANGES change company name FINANCIAL YEAR END CHANGES change financial year for for companies and close corporations ADDRESS CHANGES change company and close corporation addresses NAME SEARCH search registered and reserved names ENTERPRISE ENQUIRY enterprise details NAME EXTENSION extend reserved name expiry date TRANSACTION STATUS track transaction status BALANCE ENQUIRY customer code statement NAME TRANSFER transfer reserved name to another customer code CERTIFICATES - disclosures - B-BBEE certificates - MOI (incorporation) documents - approved names DOMAIN REGISTRATION register a domain name for your company UPDATE CONTACT DETAILS update director or member contact details for companies and close corporations COMING SOON! Loading... Please Wait... CIPC eServices v3.3 © Copyright 2018 CIPC | Terms and Conditions | Disclaimer////////////

I was expecting to see Company information(ie Company name and number, registration status), rather than that info above.

I did most things accordingly, so i do not understand what could be the issue? I am having difficulties using Jsoup lib.

Pls assist.


Viewing all articles
Browse latest Browse all 140762

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>