Android - 使用 Jsoup 库的 mutli select 查询
Android - mutli select query with Jsoup library
我在项目中工作,需要分析网站并提取所有输入以某种方式填写,我正在使用 Jsoup 库,它可以很好地处理一个查询,但使用多个查询会给出错误的行为
Document doc = Jsoup.connect(url).get();
Elements inputs = doc.select("input[type=text]");
//Elements password = doc.select("input[type=password]");
//Elements emails = doc.select("input[type=email]");
for (Element ele : inputs) {
listID.add(ele.attr("id"));
}
我的问题是如何以与网页中出现的顺序相同的顺序进行多重查询
如果我们的网站有两个输入,一个输入文本,另一个输入文本,我如何 select 两者并保存订单
<input name="username" id="login-username" class="login-input pure-u-1 " maxlength="96" tabindex="1" aria-required="true" value="" placeholder="عنوان البريد الإلكتروني" title="عنوان البريد الإلكتروني" autocorrect="off" spellcheck="false" autofocus="" type="text">
<input name="passwd" id="login-passwd" class="login-input pure-u-1" maxlength="64" tabindex="2" aria-required="true" placeholder="كلمة السر" title="كلمة السر" autocorrect="off" type="password">
虽然我不确定这是否真的是您想要的,但您可以对 select 您列出的所有元素执行此操作:
Elements inputs = doc.select("input[type=text], input[type=password], input[type=email]");
select 所有 input
元素匹配其中一种类型。
或者,甚至更简单,您可以将其用于 select 所有 input
元素:
doc.select("input");
我在项目中工作,需要分析网站并提取所有输入以某种方式填写,我正在使用 Jsoup 库,它可以很好地处理一个查询,但使用多个查询会给出错误的行为
Document doc = Jsoup.connect(url).get();
Elements inputs = doc.select("input[type=text]");
//Elements password = doc.select("input[type=password]");
//Elements emails = doc.select("input[type=email]");
for (Element ele : inputs) {
listID.add(ele.attr("id"));
}
我的问题是如何以与网页中出现的顺序相同的顺序进行多重查询 如果我们的网站有两个输入,一个输入文本,另一个输入文本,我如何 select 两者并保存订单
<input name="username" id="login-username" class="login-input pure-u-1 " maxlength="96" tabindex="1" aria-required="true" value="" placeholder="عنوان البريد الإلكتروني" title="عنوان البريد الإلكتروني" autocorrect="off" spellcheck="false" autofocus="" type="text">
<input name="passwd" id="login-passwd" class="login-input pure-u-1" maxlength="64" tabindex="2" aria-required="true" placeholder="كلمة السر" title="كلمة السر" autocorrect="off" type="password">
虽然我不确定这是否真的是您想要的,但您可以对 select 您列出的所有元素执行此操作:
Elements inputs = doc.select("input[type=text], input[type=password], input[type=email]");
select 所有 input
元素匹配其中一种类型。
或者,甚至更简单,您可以将其用于 select 所有 input
元素:
doc.select("input");