Package org.jsoup

Examples of org.jsoup.Connection$Request


        if (unparsed.trim().equals("-r")) {
            unparsed = "Special:Random";
        }

        try {
            Connection con;

            url = new URLBuilder("http://en.wikipedia.org/w/index.php");
            url.setParameter("search", unparsed);

            while (true) {
                con = Jsoup.connect(url.toString());
                con.followRedirects(false);
                con.execute();

                if (con.response().statusCode() == 200) {
                    doc = con.response().parse();
                    break;
                } else if (con.response().statusCode() == 302) {
                    url = new URLBuilder(con.response().header("Location"));
                } else {
                    channel.write("Could not find page");
                    return;
                }
            }
View Full Code Here


                // -
            }
        }

        try {
            Connection con;

            if (random) {
                url = new URLBuilder("http://www.urbandictionary.com/random.php");
            } else {
                url = new URLBuilder("http://www.urbandictionary.com/define.php");
                url.setParameter("term", unparsed);
            }

            while (true) {
                con = Jsoup.connect(url.toString());
                con.followRedirects(false);
                con.execute();

                if (con.response().statusCode() == 200) {
                    doc = con.response().parse();
                    break;
                } else if (con.response().statusCode() == 302) {
                    url = new URLBuilder(con.response().header("Location"));
                } else {
                    channel.write("Error loading page");
                    return;
                }
            }
View Full Code Here

            return;
        }

        try {
            String encodedSearchTerm = URLEncoder.encode(unparsed, "UTF8");
            Connection con;

            url = String.format("http://%s.tumblr.com/random", encodedSearchTerm);

            con = Jsoup.connect(url);
            con.execute();
            url = con.response().header("Location");
            doc = con.response().parse();

        } catch (IOException e) {
            channel.write("Error");
            return;
        }
View Full Code Here

* Implementation of {@link Connection}.
* @see org.jsoup.Jsoup#connect(String)
*/
public class HttpConnection implements Connection {
    public static Connection connect(String url) {
        Connection con = new HttpConnection();
        con.url(url);
        return con;
    }
View Full Code Here

        con.url(url);
        return con;
    }

    public static Connection connect(URL url) {
        Connection con = new HttpConnection();
        con.url(url);
        return con;
    }
View Full Code Here

* Implementation of {@link Connection}.
* @see org.jsoup.Jsoup#connect(String)
*/
public class HttpConnection implements Connection {
    public static Connection connect(String url) {
        Connection con = new HttpConnection();
        con.url(url);
        return con;
    }
View Full Code Here

        con.url(url);
        return con;
    }

    public static Connection connect(URL url) {
        Connection con = new HttpConnection();
        con.url(url);
        return con;
    }
View Full Code Here

* Implementation of {@link Connection}.
* @see org.jsoup.Jsoup#connect(String)
*/
public class HttpConnection implements Connection {
    public static Connection connect(String url) {
        Connection con = new HttpConnection();
        con.url(url);
        return con;
    }
View Full Code Here

        con.url(url);
        return con;
    }

    public static Connection connect(URL url) {
        Connection con = new HttpConnection();
        con.url(url);
        return con;
    }
View Full Code Here

  public Document getDocumentFromHttp(URL url)
    throws SoupProxy.Exception
  {
    Document doc = null;
    try {
      Connection con = Jsoup.connect(""+url);
      con.userAgent(
        System.getProperty("jc.soupproxy.useragent", "JSoup"));
      con.ignoreContentType(true);
      doc = con.get();
    }
    catch (java.lang.Exception e) {
      throw new SoupProxy.Exception(e);
    }
    return doc;
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.