当前位置: 首页>>代码示例>>Java>>正文


Java Connection.get方法代码示例

本文整理汇总了Java中org.jsoup.Connection.get方法的典型用法代码示例。如果您正苦于以下问题:Java Connection.get方法的具体用法?Java Connection.get怎么用?Java Connection.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jsoup.Connection的用法示例。


在下文中一共展示了Connection.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getWebtoon

import org.jsoup.Connection; //导入方法依赖的package包/类
/**
 * 웹툰조회
 */
public void getWebtoon(String code) {

	if (!"".equals(code)) {
		CommonService cs = new CommonService();

		Connection conn = cs.getConnection(code);
		conn.timeout(5000);

		Document doc = null;
		
		codeInputField.setText(code);
		wDesc.setWrapText(true);

		try {

			doc = conn.get();

			String title = doc.select("title").text().split("::")[0];
			setTitle(title);

			String author = doc.select("div.detail h2 > span").text();
			wTitle.setText(title + "(" + author + ")");

			String desc = doc.select("div.detail p").text();
			wDesc.setText(desc);

			String img = doc.select("div.thumb > a img").attr("src");
			thumbnail.setImage(new Image(img, true));

		} catch (Exception e) {
			e.printStackTrace();
		}
	} else {
		Platform.runLater(new Runnable() {
			@Override
			public void run() {
				AlertSupport alert = new AlertSupport("웹툰코드를 입력하세요.");
				alert.alertInfoMsg(stage);
			}
		});
	}
}
 
开发者ID:kimyearho,项目名称:WebtoonDownloadManager,代码行数:46,代码来源:ManualController.java

示例2: test

import org.jsoup.Connection; //导入方法依赖的package包/类
@Test(timeout = 7500)
public void test() throws IOException {
	//FIXME 无法执行。存在405错误。
	Base64.Encoder encoder = Base64.getEncoder();
	Connection con = Jsoup.connect("http://localhost/api/v0/auth/check_cert")
			.data("uname", encoder.encodeToString("磷".getBytes(StandardCharsets.UTF_8)))
			.data("email", encoder.encodeToString("[email protected]".getBytes(StandardCharsets.UTF_8)))
			.data("zhihu", encoder.encodeToString("ice1000".getBytes(StandardCharsets.UTF_8)))
			.data("github", encoder.encodeToString("Ray-Eldath".getBytes(StandardCharsets.UTF_8)))
			.data("stackoverflow", encoder.encodeToString("VonC".getBytes(StandardCharsets.UTF_8)))
			.data("brief", encoder.encodeToString("测试".getBytes(StandardCharsets.UTF_8)))
			.data("introduce", encoder.encodeToString("测试lalala".getBytes(StandardCharsets.UTF_8)))
			.timeout(8000);
	Document doc = con.get();
	System.out.println(doc.text());
}
 
开发者ID:ProgramLeague,项目名称:strictfp-back-end,代码行数:17,代码来源:CheckCert.java

示例3: test

import org.jsoup.Connection; //导入方法依赖的package包/类
@Test(timeout = 6000)
public void test() throws IOException {
	Connection con = Jsoup.connect("http://localhost/api/v0/misc/safecheck").data("url",
			Base64.getEncoder().encodeToString("http://www.alphamedical02.fr/".
					getBytes(StandardCharsets.UTF_8)))
			.timeout(8000);
	Document doc = con.get();
	assertEquals(doc.text(),"{\"data\":{\"en\":{\"buttons\":[\"Back\",\"Continue with a fully compreh" +
			"ension about the risks originated from this action\"],\"message\":\"The external link you're w" +
			"illing to access is considered dangerous by the ZeuS Tracker or Malware Domain List, and the de" +
			"velopers team cannot be certain about the safety of the source of the link.\\nWe won't take " +
			"any responsibility of the influence caused by continuing accessing this link. You may choose to " +
			"stop accessing and be navigated back to our site or continue accessing, but the risks originated" +
			" from this action would be considered on your own.\\nWARNING: The website you're willing to access" +
			" has been considered harmful by ZeuS Tracker or Malware Domain List.\"},\"zh_CN\":{\"buttons\":" +
			"[\"返回\",\"我已了解此行为所带来的风险并继续 \"],\"message\":\"此外链已被ZeuS Tracker或Malware Domain L" +
			"ist标注为危险网站,且开发团队无法保证此网站的安全性。\\n我们对继续访问此危险网站所致的后果不承担任何责任,您可以" +
			"选择返回或继续访问,但这将意味着您必须承担此行为所带来的风险。\\n警告:您所访问的网站已被ZeuS Tracker或Malwar" +
			"e Domain List确认为危险网站。\\n\"}},\"meta\":{\"code\":\"200\",\"message\":\"hazard query success\"}}");
}
 
开发者ID:ProgramLeague,项目名称:strictfp-back-end,代码行数:21,代码来源:SafeCheck.java

示例4: fetchResult

import org.jsoup.Connection; //导入方法依赖的package包/类
private WebSearchUnit fetchResult(Result result) {
    String link = result.getLink();
    try {
        Connection connection = Jsoup.connect(link);
        Proxy proxy = ProxyManager.getProxyIf();
        if (proxy != null) {
            connection.proxy(proxy);
        }
        Document doc = connection.get();
        String text = doc.body().text();
        LOG.debug("\nLink: {}, \nText: {}, \nSnippet: {}\n", link, text, result.getSnippet());
        return new WebSearchUnit(result, text);
    } catch (IOException e) {
        LOG.error("Failed to get page {}. Cause: {}", link, e.getMessage());
        return WebSearchUnit.emptyUnit();
    }
}
 
开发者ID:oxaoo,项目名称:mingi,代码行数:18,代码来源:WebSearchLoader.java

示例5: getGroupsList

import org.jsoup.Connection; //导入方法依赖的package包/类
@Override
public ArrayList<Group> getGroupsList(Component c, Context context) throws IOException {
    ArrayList<Group> liste = new ArrayList<>();


    String url = c.groups_url;
    Connection conn = Jsoup.connect(url);
    Document doc = conn.get();
    for (Element e : doc.select("option[value$=.html]"))
    {
        Group groupe = new Group();
        groupe.name = e.text();
        groupe.dataSourceType = DataSourceType.CELCAT;
        groupe.dataSource = getRefactoredUrl(url)+(e.attr("value").replaceAll(".html", ".xml"));
        groupe.component = c;
        liste.add(groupe);
    }
    return liste;
}
 
开发者ID:natinusala,项目名称:openedt,代码行数:20,代码来源:CelcatAdapter.java

示例6: loadParse

import org.jsoup.Connection; //导入方法依赖的package包/类
/**
 * 按照规则,加载解析html
 * @param url		:加载URL
 * @param paramMap	:请求参数
 * @param cookieMap	:请求cookie
 * @param ifPost	:是否使用post请求
 * @param tagMap	:解析规则[0-选择器方式、1-id方式、2-class方式、3-tag]
 * @return
 */
public static Elements loadParse(String url, Map<String, String> paramMap, Map<String, String> cookieMap,
        boolean ifPost, Map<Integer, Set<String>> tagMap) {
    if (!isUrl(url)) {
        return null;
    }
    try {
        // 请求设置
        Connection conn = Jsoup.connect(url);
        conn.userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36");
        if (paramMap != null && !paramMap.isEmpty()) {
            conn.data(paramMap);
        }
        if (cookieMap != null && !cookieMap.isEmpty()) {
            conn.cookies(cookieMap);
        }
        conn.timeout(5000);

        // 发出请求
        Document html = null;
        if (ifPost) {
            html = conn.post();
        } else {
            html = conn.get();
        }

        // 过滤元素
        Elements resultAll = new Elements();
        if (tagMap != null && !tagMap.isEmpty()) {
            for (Entry<Integer, Set<String>> tag : tagMap.entrySet()) {
                int tagType = tag.getKey();
                Set<String> tagNameList = tag.getValue();
                if (tagNameList != null && tagNameList.size() > 0) {
                    for (String tagName : tagNameList) {
                        if (tagType == 0) {
                            Elements resultSelect = html.select(tagName);	// 选择器方式
                            resultAll.addAll(resultSelect);
                        } else if (tagType == 1) {
                            Element resultId = html.getElementById(tagName);	// 元素ID方式
                            resultAll.add(resultId);
                        } else if (tagType == 2) {
                            Elements resultClass = html.getElementsByClass(tagName);	// ClassName方式
                            resultAll.addAll(resultClass);
                        } else if (tagType == 3) {
                            Elements resultTag = html.getElementsByTag(tagName);	// html标签方式
                            resultAll.addAll(resultTag);
                        }
                    }
                }

            }

        } else {
            resultAll = html.getElementsByTag("body");
        }
        return resultAll;
    } catch (IOException e) {
        logger.error("", e);
    }

    return null;
}
 
开发者ID:xuxueli,项目名称:xxl-incubator,代码行数:71,代码来源:JsoupUtil.java

示例7: fetchHandlesXml

import org.jsoup.Connection; //导入方法依赖的package包/类
@Test
public void fetchHandlesXml() throws IOException {
    // should auto-detect xml and use XML parser, unless explicitly requested the html parser
    String xmlUrl = "http://direct.infohound.net/tools/parse-xml.xml";
    Connection con = Jsoup.connect(xmlUrl);
    Document doc = con.get();
    Connection.Request req = con.request();
    assertTrue(req.parser().getTreeBuilder() instanceof XmlTreeBuilder);
    assertEquals("<xml> <link> one </link> <table> Two </table> </xml>", StringUtil.normaliseWhitespace(doc.outerHtml()));
}
 
开发者ID:cpusoft,项目名称:common,代码行数:11,代码来源:UrlConnectTest.java

示例8: doInBackground

import org.jsoup.Connection; //导入方法依赖的package包/类
@Override
protected String[] doInBackground(Void... params) {
    Log.d(TAG, "Fetching sync details");

    try {
        // Fetch the Giveaway page

        Connection jsoup = Jsoup.connect("https://www.steamgifts.com/account/profile/sync")
                .userAgent(Constants.JSOUP_USER_AGENT)
                .timeout(Constants.JSOUP_TIMEOUT)
                .cookie("PHPSESSID", SteamGiftsUserData.getCurrent(fragment.getContext()).getSessionId());
        Document document = jsoup.get();

        SteamGiftsUserData.extract(fragment.getContext(), document);

        // Fetch the xsrf token
        Element xsrfToken = document.select("input[name=xsrf_token]").first();
        Element lastSyncTime = document.select(".form__sync-data .notification").first();
        if (xsrfToken != null) {
            return new String[]{xsrfToken.attr("value"), lastSyncTime == null ? null : lastSyncTime.text()};
        }
    } catch (Exception e) {
        Log.e(TAG, "Error fetching URL", e);
    }
    return null;
}
 
开发者ID:SteamGifts,项目名称:SteamGifts,代码行数:27,代码来源:SyncFragment.java

示例9: parse

import org.jsoup.Connection; //导入方法依赖的package包/类
public Link parse() throws IOException {
    Link parent = null;

    do {
        visited.add(startUrl);

        Connection con = Jsoup.connect(startUrl).userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0");
        Document doc = con.get();

        Element head = doc.getElementById("firstHeading");
        Link current = new Link(startUrl, head.text());

        current.parent = parent;
        parent = current;

        Elements links = doc.getElementById("bodyContent").select("a[href]");

        for(Element link : links) {
            String url = link.absUrl("href");

            if(url.startsWith("https://en.wikipedia.org/wiki/") && url.lastIndexOf(":") == 5 && !url.contains("#")) {
                if(url.equals("https://en.wikipedia.org/wiki/Philosophy")) {
                    Link phil = new Link("https://en.wikipedia.org/wiki/Philosophy", "Philosophy");
                    phil.parent = parent;

                    return phil;
                }

                if(!visited.contains(url))
                    toVisit.add(url);
            }
        }

        startUrl = toVisit.poll();
    } while(!toVisit.isEmpty());

    return null;
}
 
开发者ID:nikmanG,项目名称:DailyProgrammer,代码行数:39,代码来源:WebParser.java

示例10: load

import org.jsoup.Connection; //导入方法依赖的package包/类
/**
 * 加载页面
 *
 * @param pageLoadInfo
 *
 * @return
 */
public static Document load(PageLoadInfo pageLoadInfo) {
    if (!UrlUtil.isUrl(pageLoadInfo.getUrl())) {
        return null;
    }
    try {
        // 请求设置
        Connection conn = Jsoup.connect(pageLoadInfo.getUrl());
        if (pageLoadInfo.getParamMap() != null && !pageLoadInfo.getParamMap().isEmpty()) {
            conn.data(pageLoadInfo.getParamMap());
        }
        if (pageLoadInfo.getCookieMap() != null && !pageLoadInfo.getCookieMap().isEmpty()) {
            conn.cookies(pageLoadInfo.getCookieMap());
        }
        if (pageLoadInfo.getHeaderMap()!=null && !pageLoadInfo.getHeaderMap().isEmpty()) {
            conn.headers(pageLoadInfo.getHeaderMap());
        }
        if (pageLoadInfo.getUserAgent()!=null) {
            conn.userAgent(pageLoadInfo.getUserAgent());
        }
        if (pageLoadInfo.getReferrer() != null) {
            conn.referrer(pageLoadInfo.getReferrer());
        }
        conn.timeout(pageLoadInfo.getTimeoutMillis());

        // 代理
        if (pageLoadInfo.getProxy() != null) {
            conn.proxy(pageLoadInfo.getProxy());
        }

        // 发出请求
        Document html = null;
        if (pageLoadInfo.getIfPost()) {
            html = conn.post();
        } else {
            html = conn.get();
        }
        return html;
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        return null;
    }
}
 
开发者ID:xuxueli,项目名称:xxl-crawler,代码行数:50,代码来源:JsoupUtil.java

示例11: getDocument

import org.jsoup.Connection; //导入方法依赖的package包/类
public static Document getDocument(String url, boolean loginCoolApk) throws IOException {
    if (!url.startsWith("https://") || !url.startsWith("http://"))
        url = "http://" + url;
    Connection connection = Jsoup.connect(url);
    if (loginCoolApk) {
        connection.cookies(new UserSave().buildWebRequestCookie());
    }
    return connection.get();
}
 
开发者ID:TaRGroup,项目名称:CoolApk-Console,代码行数:10,代码来源:JsoupUtil.java

示例12: test

import org.jsoup.Connection; //导入方法依赖的package包/类
@Test
@TestOnly
public void test() throws IOException {
	Connection con = Jsoup.connect("http://strictfp.duapp.com/timeline")
			.data("start", "2017-01-01")
			.data("end", "2017-01-02").timeout(8000);
	Document doc = con.get();
	System.out.println(doc.text());
}
 
开发者ID:ProgramLeague,项目名称:strictfp-back-end,代码行数:10,代码来源:TimeLine.java

示例13: test

import org.jsoup.Connection; //导入方法依赖的package包/类
@Test
@TestOnly
public void test() throws IOException {
	Connection con = Jsoup.connect("http://localhost:40000/api/v0/user").data("name", "\"Eldath\"").timeout(80000);
	Document doc = con.get();
	System.out.println(doc.text());
}
 
开发者ID:ProgramLeague,项目名称:strictfp-back-end,代码行数:8,代码来源:User.java

示例14: get

import org.jsoup.Connection; //导入方法依赖的package包/类
/**
 * Gets the HTML source of a web page.
 * 
 * @param url The URL to scrape.
 * @return A JSoup Document representing the page scraped.
 */
public static Document get(String url) {
	try {
		// before downloading the page, wait for the min delay to pass
		if (timer == null) {
			updateMinDelay();
		} else {
			synchronized (timer) {
				timer.wait();
			}
		}
		
		Connection conn = Jsoup.connect(url);
		
		if (Settings.USE_AUTH && Settings.AUTH_COOKIE != null) {
			// to log in, we need two cookies from the user, called "a" and "b" by FA.
			
			//find cookie A
			Matcher m = Pattern.compile("a=([a-fA-F0-9\\-]+)").matcher(Settings.AUTH_COOKIE);
			if (m.find()) {
				String a = m.group(1);
				conn = conn.cookie("a", a);
			}
			
			//find cookie B
			m = Pattern.compile("b=([a-fA-F0-9\\-]+)").matcher(Settings.AUTH_COOKIE);
			if (m.find()) {
				String b = m.group(1);
				conn = conn.cookie("b", b);
			}
		}
		return conn.get();
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:ThatGreyDragon,项目名称:who2comm,代码行数:43,代码来源:ConnectionManager.java

示例15: getWeather

import org.jsoup.Connection; //导入方法依赖的package包/类
@Override
public Weather getWeather() throws IOException {
    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);

    String main = "https://gismeteo.com";

    Connection connection = Jsoup.connect(main).timeout(5000);
    Document document = connection.get();
    Element temp = document.getElementsByClass("temp").get(0);
    String current_temperature = temp.getElementsByClass("c").text();
    boolean belowZero = current_temperature.charAt(0) != '0' && current_temperature.charAt(0) != '+';
    current_temperature = current_temperature.substring(1, current_temperature.length() - 2);
    if (current_temperature.isEmpty())
        current_temperature = "0";
    String measurements = temp.getElementsByClass("meas").get(0).text();
    String conditionStr = document.getElementsByClass("cloudness").first().getElementsByTag("td").text();


    connection = Jsoup.connect(document.getElementsByClass("fcast").select("a").attr("abs:href"));
    document = connection.get();
    temp = document.getElementsByClass("swtab").first().getElementsByClass("temp").get(0);
    String high_temperature = " " + temp.getElementsByClass("c").get(1).text() + measurements.substring(0, 1);
    String low_temperature = " " + temp.getElementsByClass("c").get(0).text() + measurements.substring(0, 1);

    WeatherCondition condition = WeatherCondition.condition(conditionStr);

    return new Weather(condition, belowZero, current_temperature, high_temperature, low_temperature, measurements);
}
 
开发者ID:YanDoroshenko,项目名称:Klok,代码行数:30,代码来源:GismeteoParser.java


注:本文中的org.jsoup.Connection.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。