目标是通过Java JSoup从Dice.com等网站解析HTML页面,并将查询文本(如“Informatica”)提交到该搜索表单字段中。
我正在使用Java JSoup,但对其他技术,Java或其他技术开放。
以下是Dice的一个片段,其中包含我正在尝试提交的HTML表单字段示例。
我没有从System.out收到任何回复,表明搜索“Informatica”已成功发布到表单字段。考虑到下面列出的Dice表单,你如何通过搜索进行POST?
Connection.Response form = Jsoup.connect("https://www.dice.com").method(Connection.Method.GET).execute();
Document document = Jsoup.connect("https://www.dice.com/jobs")
.data("cookieexists", "false")
.data("search-form", "Informatica")
.data("q", "Informatica")
.data("search-field-keyword", "Informatica")
.cookies(form.cookies())
.post();
System.out.println(document);
来自Dice HTML源代码的示例:
<form class="search-form" action="/jobs" method="GET" id="search-form">
<fieldset class="row">
<div class="col-xs-12">
<div class="form-group">
<strong class="title">Search across 77,990 Tech Jobs</strong>
</div>
</div>
<div class="col-md-6 col-sm-5">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><label for="search-field-keyword"
class="icon- magnifier"></label></div>
<input type="search" class="form-control input-lg" placeholder="Job title
or keywords" id="search-field-keyword" name="q" autofocus autocomplete="off">
</div>
<div class="help-block">job title, skills, keywords or company name</div>
</div>
</div>
<div class="col-md-3 col-sm-4">
<div class="form-group">
<div class="input-group">
<div class="input-group-addon"><label for="search-field-location"
class="icon-compass-3"></label></div>
<input type="search" class="form-control input-lg" placeholder="Location"
id="search-field-location" name="l" autocomplete="off">
</div>
<div class="help-block">zip code, city or state</div>
</div>
</div>
<div class="col-sm-3">
<div class="row">
<div class="col-sm-12 col-xs-8">
<button type="submit" class="btn btn-primary btn-lg btn-block">Find Tech
Jobs</button>
</div>
<div class="col-sm-12 col-xs-4">
<div class="text-right help-block link-as"><a href="/jobs
/advancedSearch.html"><span class="icomoon-equalizer"></span> Advanced <span
class="txt-search">Search</span></a></div>
</div>
</div>
</div>
</fieldset>
</form>