Package org.jsoup

Examples of org.jsoup.Connection$Request


        assertEquals("", res.cookie("three"));
        assertEquals("data", res.cookie("four"));
    }

    @Test public void connectWithUrl() throws MalformedURLException {
        Connection con = HttpConnection.connect(new URL("http://example.com"));
        assertEquals("http://example.com", con.request().url().toExternalForm());
    }
View Full Code Here


        Connection con = HttpConnection.connect(new URL("http://example.com"));
        assertEquals("http://example.com", con.request().url().toExternalForm());
    }

    @Test(expected=IllegalArgumentException.class) public void throwsOnMalformedUrl() {
        Connection con = HttpConnection.connect("bzzt");
    }
View Full Code Here

    @Test(expected=IllegalArgumentException.class) public void throwsOnMalformedUrl() {
        Connection con = HttpConnection.connect("bzzt");
    }

    @Test public void userAgent() {
        Connection con = HttpConnection.connect("http://example.com/");
        con.userAgent("Mozilla");
        assertEquals("Mozilla", con.request().header("User-Agent"));
    }
View Full Code Here

        con.userAgent("Mozilla");
        assertEquals("Mozilla", con.request().header("User-Agent"));
    }

    @Test public void timeout() {
        Connection con = HttpConnection.connect("http://example.com/");
        con.timeout(1000);
        assertEquals(1000, con.request().timeout());
    }
View Full Code Here

        con.timeout(1000);
        assertEquals(1000, con.request().timeout());
    }

    @Test public void referrer() {
        Connection con = HttpConnection.connect("http://example.com/");
        con.referrer("http://foo.com");
        assertEquals("http://foo.com", con.request().header("Referer"));
    }
View Full Code Here

        con.referrer("http://foo.com");
        assertEquals("http://foo.com", con.request().header("Referer"));
    }

    @Test public void method() {
        Connection con = HttpConnection.connect("http://example.com/");
        assertEquals(Connection.Method.GET, con.request().method());
        con.method(Connection.Method.POST);
        assertEquals(Connection.Method.POST, con.request().method());
    }
View Full Code Here

        con.method(Connection.Method.POST);
        assertEquals(Connection.Method.POST, con.request().method());
    }

    @Test(expected=IllegalArgumentException.class) public void throwsOnOdddData() {
        Connection con = HttpConnection.connect("http://example.com/");
        con.data("Name", "val", "what");
    }
View Full Code Here

        Connection con = HttpConnection.connect("http://example.com/");
        con.data("Name", "val", "what");
    }

    @Test public void data() {
        Connection con = HttpConnection.connect("http://example.com/");
        con.data("Name", "Val", "Foo", "bar");
        Collection<Connection.KeyVal> values = con.request().data();
        Object[] data =  values.toArray();
        Connection.KeyVal one = (Connection.KeyVal) data[0];
        Connection.KeyVal two = (Connection.KeyVal) data[1];
        assertEquals("Name", one.key());
        assertEquals("Val", one.value());
View Full Code Here

        assertEquals("Foo", two.key());
        assertEquals("bar", two.value());
    }

    @Test public void cookie() {
        Connection con = HttpConnection.connect("http://example.com/");
        con.cookie("Name", "Val");
        assertEquals("Val", con.request().cookie("Name"));
    }
View Full Code Here

    String cqurl = "http://www.hq6m.com/game/?mod=cai&act=board&cai_id=1";
    String jxurl = "http://www.hq6m.com/game/?mod=cai&act=board&cai_id=2";
   
    try {
     
      Connection conn = ConnectionManager.getInstance().getConnection(cqurl);
//      conn.cookie("id", "21");
      conn.cookie("PcAicaip", "3307f%2FVmMBYVuaqdGe8QIi6otjFMA7yaPM%2Bh%2Fg3Gk1K2o4VadpS%2B3dFciwhDSxqYTnA%2F9KqvHrt0JECP3pc%2FxksZwewPkoJ27ZVdjXs2cxaWKmKLyLx5ljyn%2B%2Bitpg%2FqWq6yvHP%2FCypVgdU%2BBntiEGYC%2BYvrSrb83V7ceawUHWE");
      conn.cookie("PcAicain", "haha");
      conn.cookie("playTimes06481010C78141AB89F3EBBC43A1E9A9", "0");
      conn.cookie("5pao_VID_06481010C78141AB89F3EBBC43A1E9A9", "true");
      Document doc = conn.post();
      String res = doc.text();
      res = res.substring(res.indexOf("{"), res.indexOf("}")+1);
      JSONObject obj = JSONObject.fromObject(res);
      String title = obj.getString("title");
      String numbers = obj.getString("numbers");
     
      System.out.println("CQ>>> "+title+": "+numbers);
     
      conn = ConnectionManager.getInstance().getConnection(jxurl);
//      conn.cookie("id", "21");
      conn.cookie("PcAicaip", "3307f%2FVmMBYVuaqdGe8QIi6otjFMA7yaPM%2Bh%2Fg3Gk1K2o4VadpS%2B3dFciwhDSxqYTnA%2F9KqvHrt0JECP3pc%2FxksZwewPkoJ27ZVdjXs2cxaWKmKLyLx5ljyn%2B%2Bitpg%2FqWq6yvHP%2FCypVgdU%2BBntiEGYC%2BYvrSrb83V7ceawUHWE");
      conn.cookie("PcAicain", "haha");
      conn.cookie("playTimes06481010C78141AB89F3EBBC43A1E9A9", "0");
      conn.cookie("5pao_VID_06481010C78141AB89F3EBBC43A1E9A9", "true");
      doc = conn.post();
      res = doc.text();
      res = res.substring(res.indexOf("{"), res.indexOf("}")+1);
      obj = JSONObject.fromObject(res);
      title = obj.getString("title");
      numbers = obj.getString("numbers");
View Full Code Here

TOP

Related Classes of org.jsoup.Connection$Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.