use of org.jsoup.nodes.Document in project jsoup by jhy.
the class UrlConnectTest method followsRelativeRedirect.
@Test
public void followsRelativeRedirect() throws IOException {
// to /tidy/
Connection con = Jsoup.connect("http://direct.infohound.net/tools/302-rel.pl");
Document doc = con.post();
assertTrue(doc.title().contains("HTML Tidy Online"));
}
use of org.jsoup.nodes.Document in project jsoup by jhy.
the class UrlConnectTest method redirectsResponseCookieToNextResponse.
@Test
public void redirectsResponseCookieToNextResponse() throws IOException {
Connection con = Jsoup.connect("http://direct.infohound.net/tools/302-cookie.pl");
Connection.Response res = con.execute();
// confirms that cookies set on 1st hit are presented in final result
assertEquals("asdfg123", res.cookie("token"));
Document doc = res.parse();
// confirms that redirected hit saw cookie
assertEquals("token=asdfg123; uid=jhy", ihVal("HTTP_COOKIE", doc));
}
use of org.jsoup.nodes.Document in project jsoup by jhy.
the class UrlConnectTest method fetchURl.
@Test
public void fetchURl() throws IOException {
// no trailing / to force redir
String url = "https://jsoup.org";
Document doc = Jsoup.parse(new URL(url), 10 * 1000);
assertTrue(doc.title().contains("jsoup"));
}
use of org.jsoup.nodes.Document in project jsoup by jhy.
the class ParseTest method testSmhBizArticle.
@Test
public void testSmhBizArticle() throws IOException {
File in = getFile("/htmltests/smh-biz-article-1.html");
Document doc = Jsoup.parse(in, "UTF-8", "http://www.smh.com.au/business/the-boards-next-fear-the-female-quota-20100106-lteq.html");
assertEquals("The board’s next fear: the female quota", // note that the apos in the source is a literal ’ (8217), not escaped or '
doc.title());
assertEquals("en", doc.select("html").attr("xml:lang"));
Elements articleBody = doc.select(".articleBody > *");
assertEquals(17, articleBody.size());
// todo: more tests!
}
use of org.jsoup.nodes.Document in project jsoup by jhy.
the class UrlConnectTest method inWildUtfRedirect2.
@Test
public void inWildUtfRedirect2() throws IOException {
Connection.Response res = Jsoup.connect("https://ssl.souq.com/sa-en/2724288604627/s").execute();
Document doc = res.parse();
assertEquals("http://saudi.souq.com/sa-en/%D8%AE%D8%B2%D9%86%D8%A9-%D8%A2%D9%85%D9%86%D8%A9-3-%D8%B7%D8%A8%D9%82%D8%A7%D8%AA-%D8%A8%D9%86%D8%B8%D8%A7%D9%85-%D9%82%D9%81%D9%84-%D8%A5%D9%84%D9%83%D8%AA%D8%B1%D9%88%D9%86%D9%8A-bsd11523-6831477/i/?ctype=dsrch", doc.location());
}
Aggregations