samedi 5 août 2017

How can I crawling post data using jsoup?

I want to parse division code and cinema ID from this site

link

I try use jsoup api to parse this site but, return message always paramlist is missing

Here is my some code

Document document = Jsoup.connect(URL)
                .data("MethodName", "GetCinemaItems")
                .data("channelType", "MW")
                .data("osType", "Chrome")
                .data("osVersion", "Mozilla/5.0")
                .referrer("http://ift.tt/2fii21P")
                .cookie("referrerUrl","http%3A%2F%2Fwww.lottecinema.co.kr%2Flcmw%2Fcontents%2Fcinema%2Fcinema-select.aspx")
                .post();

and I try method not using jsoup

String param = "{\"MethodName\":\"GetCinemaDivision\",\"channelType\":\"MW\",\"osType\":\"Chrome\",\"osVersion\":\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36\"}";

        java.net.URL url = new java.net.URL(URL);
        HttpURLConnection con = (HttpURLConnection) url.openConnection();

        con.setRequestMethod("POST");
        con.setRequestProperty("Accept", "application/json");
        con.setRequestProperty("Accept-Encoding", "gzip, deflate");
        con.setRequestProperty("Accept-Language", "ko-KR,ko;q=0.8,en-US;q=0.6,en;q=0.4");
        con.setRequestProperty("Connection","keep-alive");
        con.setRequestProperty("Referer","http://ift.tt/2fii21P");
        con.setRequestProperty("X-Requested-With","XMLHttpRequest");

        OutputStreamWriter w = new OutputStreamWriter(con.getOutputStream(), "UTF-8");

        w.write(param);
        w.close();

        int responsecode = con.getResponseCode();

        BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

        String inputLine;
        StringBuffer response = new StringBuffer();

        while((inputLine = in.readLine()) != null)
            response.append(inputLine);

        in.close();

But, receive error param is missing

this is my first clawing please understand my shortage.. :)

Thank you!! have a nice day

Aucun commentaire:

Enregistrer un commentaire