如何在.java中使用Regex获取像facebook这样的页面元素(标题,描述,图像)
有没有人知道JSPath转换器的xPath?我从Chrome获得以下xPath:
//*[@id="docs"]/div[1]/h4/a
Run Code Online (Sandbox Code Playgroud)
并希望将其更改为Jsoup查询.该路径包含我想要引用的href.
我有一个愚蠢的问题:我正在尝试将Jsoup库(它只是一个外部jar)添加到我在Intellij Idea中开发的android应用程序中,它似乎并且做得不对.我把库放在libs文件夹中,然后我进入了Project Structure - > modules和selected dependencies,选择add global library,选择attach source并单击ok.
当我编写代码时,它能够自动导入类并进行编译,但在运行时我得到"java.lang.NoClassDefFoundError:org.jsoup.Jsoup"
我使用JSoup使用以下代码发布值:
Document document = Jsoup.connect("http://www......com/....php")
.data("user","user","password","12345","email","info@tutorialswindow.com")
.method(Method.POST)
.execute()
.parse();
Run Code Online (Sandbox Code Playgroud)
现在我也想提交一份文件.就像带有文件字段的表单一样.这可能吗 ?如果比怎么样?
您可以使用Jsoup向Google提交搜索,但不是通过"Google搜索"发送您的请求,而是使用"我感觉很幸运"吗?我想捕获将返回的网站的名称.
我看到很多提交表单的例子,但从来没有办法指定一个特定的按钮来执行搜索或表单提交.
如果Jsoup不起作用,会怎么样?
您好我正在尝试在Document根元素中插入一个新的子元素,如下所示:
Document doc = Jsoup.parse(doc);
Elements els = doc.getElementsByTag("root");
for (Element el : els) {
Element j = el.appendElement("child");
}
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,文档中只有一个根标记,因此循环只运行一次.
无论如何,元素作为根元素"root"的最后一个元素插入.
有什么办法可以插入一个子元素作为第一个元素吗?
例:
<root>
<!-- New Element must be inserted here -->
<child></child>
<child></chidl>
<!-- But it is inserted here at the bottom insted -->
</root>
Run Code Online (Sandbox Code Playgroud) 在HTML页面中,我想选择一个javascript变量的值.以下是HTML页面的摘要.
<input id="hidval" value="" type="hidden">
<form method="post" style="padding: 0px;margin: 0px;" name="profile" autocomplete="off">
<input name="pqRjnA" id="pqRjnA" value="" type="hidden">
<script type="text/javascript">
key="pqRjnA";
</script>
Run Code Online (Sandbox Code Playgroud)
我的目标是key使用此页面读取变量的值jsoup.有可能jsoup吗?如果是的话怎么样?
我目前正在处理一个<ul>包含许多第一级<li>元素的元素.我想得到那些元素,只有那些元素.但是,当我使用Jsoup选择器或getElementsByTag获取它们时,它还会返回<li>这些第一级<li>元素中的元素.
我该怎么做才能获得第一级<li>元素?
这是代码:
Elements bundleList = indieGala.select("section.games_bundle_box2")
.get(0).select("ul.unlock")
.get(0).getElementsByTag("li");
Run Code Online (Sandbox Code Playgroud)
这是html:
<section class="games_bundle_box2">
<div class="games-container">
<!-- List Game Unlocked -->
<ul class="unlock">
<!-- Item -->
<li>
<!-- Preview Thumb -->
<a href="#game1" class="fancybox-various" title="Desura & Steam for Windows and Mac - This game has been GreenLighted on Steam and all buyers of The IndieGala Flashpoint bundle will receive Steam keys in a few weeks!">
<span class="tier1">
Pay minimum
<em class="color-text">
$1 …Run Code Online (Sandbox Code Playgroud)