【发布时间】:2021-07-12 07:55:16
【问题描述】:
我正在尝试通过 HtmlUnit 在https://tax.ocgov.com/tcweb/search_page.asp 上查找有效的包裹编号,因此我使用了以下 for 循环:
for (Integer pID=34056101; pID<34056111; pID++) {
HtmlPage page = webClient.getPage("https://tax.ocgov.com/tcweb/search_page.asp");
String i = pID.toString();
final HtmlForm form = page.getFormByName("searchparcel");
final HtmlTextInput taxIDInput = form.getInputByName("t_parcel_no");
final HtmlImageInput button = form.getInputByName("s_parcel");
taxIDInput.type(i);
final HtmlPage page2 = (HtmlPage) button.click();
//System.out.println(page2.getUrl().getPath());
if (page2.getUrl().getPath() == "/tcweb/search_parcel.asp")
{writer.println(pID);}
}
但是,我收到了这个错误:
com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 不是 找到https://tax.ocgov.com/includes/jquery-2.2.3.min.js
异常是由这行代码引起的:
final HtmlPage page2 = (HtmlPage) button.click();
我应该怎么做才能让我的程序正常运行?
【问题讨论】:
标签: java http-status-code-404 htmlunit