本文整理汇总了Java中org.jsoup.nodes.Element.text方法的典型用法代码示例。如果您正苦于以下问题:Java Element.text方法的具体用法?Java Element.text怎么用?Java Element.text使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jsoup.nodes.Element
的用法示例。
在下文中一共展示了Element.text方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractContent
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String extractContent(String url) {
String summary = "";
try {
Document doc = Jsoup.connect(url).get();
Element element = doc.getElementById("intro").child(1);
if (element.childNodeSize() == 2) {
Element target = element.getElementsByClass("hidden").get(0);
summary = target.text();
} else {
summary = element.text();
}
} catch (Exception e) {
e.printStackTrace();
}
return summary;
}
示例2: doAnalysis
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List doAnalysis(String html) {
List<Major> list = new ArrayList<Major>();
Element element = null;
Elements options = null;
element=HTMLUtil.getSelectorByName(html, Constants.HTML_ELEMENT_NAME.SELECT_NAME_MAJOR.getValue());
if (element != null) {
options = element.children();
Major major = null;
for (Element e : options) {
if (e.val().equals("")||e.text()==null||e.text().trim().equals("")||e.val().equals("Nothing"))
continue;
major = new Major();
major.setName(HTMLUtil.cutName(e.text()));
major.setNo(e.attr("value"));
Academy academy=new Academy();
academy.setNo(academyNo);
major.setAcademy(academy);
list.add(major);
}
}
return list;
}
示例3: parseElement
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
/**
* 抽取元素数据
*
* @param fieldElement
* @param selectType
* @param selectVal
* @return
*/
public static String parseElement(Element fieldElement, XxlCrawlerConf.SelectType selectType, String selectVal) {
String fieldElementOrigin = null;
if (XxlCrawlerConf.SelectType.HTML == selectType) {
fieldElementOrigin = fieldElement.html();
} else if (XxlCrawlerConf.SelectType.VAL == selectType) {
fieldElementOrigin = fieldElement.val();
} else if (XxlCrawlerConf.SelectType.TEXT == selectType) {
fieldElementOrigin = fieldElement.text();
} else if (XxlCrawlerConf.SelectType.ATTR == selectType) {
fieldElementOrigin = fieldElement.attr(selectVal);
} else if (XxlCrawlerConf.SelectType.HAS_CLASS == selectType) {
fieldElementOrigin = String.valueOf(fieldElement.hasClass(selectVal));
} else {
fieldElementOrigin = fieldElement.toString();
}
return fieldElementOrigin;
}
示例4: check
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public static UpdateInfo check (Market market, String packageName) throws IOException{
Document document;
UpdateInfo info = new UpdateInfo();
info.mMarket = market;
info.mPackageName = packageName;
switch (market) {
case MARKET_COOLAPK:
document = Jsoup.connect("http://coolapk.com/apk/" + packageName).get();
info.mVersionName = document.select("dl.dl-horizontal").get(0).select("dd").get(2).text();
info.mChangeLog = document.select("div.ex-card-wrapper").get(3).html();
return info;
case MARKET_GOOGLEPLAY:
document = Jsoup.connect("https://play.google.com/store/apps/details?id=" + packageName).get();
info.mVersionName = document.select("div[itemprop=softwareVersion]").get(0).html();
Elements elements = document.select("div.recent-change");
String changeLog = "";
for (Element element : elements) {
changeLog += element.text();
}
info.mChangeLog = changeLog;
return info;
case MARKET_WANDOUJIA :
document = Jsoup.connect("http://www.wandoujia.com/apps/" + packageName).get();
info.mVersionName = document.select("div[class=con]").get(0).text().substring(3);
info.mChangeLog = document.select("div[class=con]").get(1).html();
return info;
}
return null;
}
示例5: getData
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public void getData(String link,TreeMap<String, Integer> frequencyData)
{
int count = 0;
try
{
Trie myTrie = new Trie();
Document document = Jsoup.connect(link).get();
Elements paragraph = document.select("p");
for(Element para : paragraph)
{
String p = para.text();
p = p.replaceAll("[,.!?:;()-]", "\\s");
for (String word : p.split(" ")) {
if (StopWord.is(word.toLowerCase())) continue;
myTrie.insert(word.toLowerCase());
count = PageRanking.getCount(word, frequencyData) + 1 ;
frequencyData.put(word, count);
}
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
示例6: collectDetail
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private TorrentDetail collectDetail(String body) {
TorrentDetail detail = new TorrentDetail();
Map<String, String> info = new HashMap<>();
//获取种子信息
Document doc = Jsoup.parse(body);
if(doc.select("dl").size() < 1) {
return null;
}
Elements dtEles = doc.getElementsByTag("dt");
Elements ddEles = doc.getElementsByTag("dd");
if(dtEles.size() == ddEles.size()) {
for(int i = 0; i < dtEles.size() - 1; i++) {
String key = dtEles.get(i).text().trim();
key = key.substring(0, key.length() - 1);
String value = ddEles.get(i).text().trim();
info.put(key, value);
}
}
detail.setInfo(info);
//获取种子的磁力链接
Element linkEle = doc.select("div.download a").first();
String link = linkEle.attr("href");
detail.setLink(link);
//获取种子的介绍
Element introEle = doc.select("div.nfo pre").first();
String intro = introEle.text();
detail.setIntro(intro);
return detail;
}
示例7: themeFromElement
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private static HtmlCssTheme themeFromElement(Element element) {
Element titleElement = element.select(".title a").first();
String title = titleElement.text();
String url = HttpUrl.parse(HOST + titleElement.attr("href"))
.newBuilder()
.addQueryParameter("ref", affilaiteCode)
.build().toString();
String imageUrl = HOST + element.select(".imgWrap img").attr("src");
int downloads = Optional.of(element.select(".sales").text())
.filter(val -> !Strings.isNullOrEmpty(val))
.map(val -> val.replace(" sales", ""))
.map(Integer::parseInt)
.orElse(0);
return new HtmlCssTheme(title, url, imageUrl, downloads);
}
示例8: convert
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public Weather convert(Element node, Selector selector) {
String text = node.text();
int offset = text.indexOf("Weather");
offset += "Weather is ".length();
text = text.substring(offset);
return new Weather(text);
}
示例9: parseInfoItems
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public List<InfoItem> parseInfoItems(String body) {
Elements items = Jsoup.parseBodyFragment(body).getElementsByClass("list-art").get(0).children();
ArrayList<InfoItem> infoItems = new ArrayList<>(items.size());
for (Element item : items) {
Element a = item.getElementsByTag("a").get(0);
InfoItem infoItem = new InfoItem(a.text(),
item.getElementsByTag("span").get(0).text()
, SITE + a.attr("href"));
infoItems.add(infoItem);
}
return infoItems;
}
示例10: parse
import org.jsoup.nodes.Element; //导入方法依赖的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;
}
示例11: getDescription
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
@Override
public String getDescription() throws ParsingException {
Element desEl = el.select("div[class*=\"yt-lockup-description\"]").first();
if (desEl == null) {
return "";
} else {
return desEl.text();
}
}
示例12: getValue
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String getValue(Element element, String attrName) {
if (attrName == null) {
return element.outerHtml();
} else if ("innerHtml".equalsIgnoreCase(attrName)) {
return element.html();
} else if ("text".equalsIgnoreCase(attrName)) {
return getText(element);
} else if ("allText".equalsIgnoreCase(attrName)) {
return element.text();
} else {
return element.attr(attrName);
}
}
示例13: Incident
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private Incident(Element message) {
String timestamp = message.getElementsByTag("small").first().text();
String description = message.text();
this.timestamp = parseTimestamp(timestamp);
this.status = ServerStatus.get(message.getElementsByTag("strong").first().text());
this.description = description.replace(new StringBuilder(timestamp).append(" ").append(status).append(" - "), "");
}
示例14: getValue
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
private String getValue(Element element) {
if (attrName == null) {
return element.outerHtml();
} else if ("innerHtml".equalsIgnoreCase(attrName)) {
return element.html();
} else if ("text".equalsIgnoreCase(attrName)) {
return getText(element);
} else if ("allText".equalsIgnoreCase(attrName)) {
return element.text();
} else {
return element.attr(attrName);
}
}
示例15: getList
import org.jsoup.nodes.Element; //导入方法依赖的package包/类
public List<MagneticModel> getList() {
List<MagneticModel> listModels = new ArrayList<>();
MagneticModel magneticModel;
Elements a = document.select("div.list").select("a[href]:not(.desc):not(.asc)");
for (Element element : a) {
if (!TextUtils.equals("点击搜索", element.text())) {
magneticModel = new MagneticModel();
magneticModel.title = element.text();
magneticModel.url = element.select("a[href]").attr("abs:href");
listModels.add(magneticModel);
}
}
return listModels;
}