zoukankan      html  css  js  c++  java
  • getIcourse163ByPage

    public static String getIcourse163ByPage(String pageIndex) throws IOException {
            String urlStart = "http://www.icourse163.org/category/all#?type=30&orderBy=0&pageIndex=1";
            Connection con = Jsoup.connect(urlStart);
            Connection.Response resp = con.method(Connection.Method.GET).execute();
            Map<String,String> cookies = resp.cookies();
            Map<String,String> headers = resp.headers();
    
            String url = "http://www.icourse163.org/web/j/courseBean.getCoursePanelListByFrontCategory.rpc?csrfKey=";
            Connection con2 = Jsoup.connect(url);
            con2.cookies(cookies);
            if (headers != null) {
                for (Map.Entry<String, String> entry : headers.entrySet()) {
                    //添加参数
                    con2.header(entry.getKey(), entry.getValue());
                }
            }
            con2.header("Content-Type","application/x-www-form-urlencoded");
    
    
            con2.data("csrfKey", "");
            con2.data("categoryId", "-1");
            con2.data("type", "30");
            con2.data("orderBy", "0");
            con2.data("pageIndex", pageIndex);
    //        con2.data("pageIndex", "5");
            con2.data("pageSize", "20");
    
            Document doc = null;
            try {
                doc = con2.ignoreContentType(true).post();
            } catch (IOException e) {
                e.printStackTrace();
            }
            //System.out.println(doc.body());
    
            return doc.body().outerHtml();
        }
    
    
        public static void main(String[] args) throws IOException {
    //        Icourse163Spider.getOnePageFromPANSOU_("http://www.icourse163.org/category/all#?type=30&orderBy=0&pageIndex=56");
    //        String url = "http://www.icourse163.org/category/all#?type=30&orderBy=0&pageIndex=56";
    //        Icourse163Spider.httpGetHeader(url, "", "");
    //        String urlJson = "http://www.icourse163.org/web/j/courseBean.getCoursePanelListByFrontCategory.rpc?csrfKey=0e0a679fd3804fcc94e19d3e434d61e2";
    //        Icourse163Spider.httpPost(urlJson, headersOne, "");
    
    
            for(int i=5;i<56;i++) {
                FileUtils.writeToFile("d://icourse163//" + i + ".txt", getIcourse163ByPage("" + i), false);
                try {
                    Thread.sleep(1000*3);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
    
        }
  • 相关阅读:
    uva 489 Hangman Judge(水题)
    中国海洋大学第四届朗讯杯高级组 Cash Cow(模拟)
    中国海洋大学第四届朗讯杯高级组 A 2718 Rocky(模拟)
    poj 1039 Pipe(叉乘。。。)
    CodeForces 135 B. Rectangle and Square(判断正方形和 矩形)
    poj 1265 Area( pick 定理 )
    poj 2031 Building a Space Station(prime )
    hdu 4502 吉哥系列故事——临时工计划(dp)
    拉格朗日插值
    [USACO18DEC]The Cow Gathering P
  • 原文地址:https://www.cnblogs.com/yasepix/p/8445230.html
Copyright © 2011-2022 走看看