gpt4 book ai didi

java - html单元 : An invalid or illegal selector was specified

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:46:21 31 4
gpt4 key购买 nike

我正在尝试使用 htmlunit 模拟登录。虽然我根据示例编写了代码,但还是遇到了一个无聊的问题。以下是我从控制台获取的一些消息。

runtimeError: message=[An invalid or illegal selector was specified (selector: '*,:x'         error: Invalid selector: *:x).] sourceName=[http://user.mofangge.com/Scripts/inc/jquery-1.10.2.js] line=[1640] lineSource=[null] lineOffset=[0]

WARNING: Obsolete content type encountered: 'application/x-javascript'.

CSS error: 'http://user.mofangge.com/Content/Css/Style1/Main.css' [1:1] Error in style sheet. (Invalid token "\u9518". Was expecting one of: <EOF>, <S>, <IDENT>, "<!--", "-->", <HASH>, <IMPORT_SYM>, <PAGE_SYM>, <MEDIA_SYM>, <FONT_FACE_SYM>, <CHARSET_SYM>, ".", ":", "*", "[", <ATKEYWORD>.)

Aug 11, 2014 1:43:27 下午 com.gargoylesoftware.htmlunit.DefaultCssErrorHandler error

CSS error: 'http://user.mofangge.com/Content/Css/Style1/Login.css' [1:1] Error in style sheet. (Invalid token "\u9518". Was expecting one of: <EOF>, <S>, <IDENT>, "<!--", "-->", <HASH>, <IMPORT_SYM>, <PAGE_SYM>, <MEDIA_SYM>, <FONT_FACE_SYM>, <CHARSET_SYM>, ".", ":", "*", "[", <ATKEYWORD>.)

runtimeError: message=[An invalid or illegal selector was specified (selector: ':input' error: Invalid selector: *:input).] sourceName=[http://user.mofangge.com/Scripts/inc/jquery-1.10.2.js] line=[1275] lineSource=[null] lineOffset=[0]

这是我的代码。我没有得到任何有用的东西。我不知道为什么会这样,希望得到任何帮助。

    WebClient webClient = new WebClient(BrowserVersion.CHROME);     
webClient.getOptions().setCssEnabled(true);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setTimeout(10000);

DefaultCredentialsProvider credentialsProvider = (DefaultCredentialsProvider)webClient.getCredentialsProvider();
credentialsProvider.addCredentials("username", "password");


HtmlPage page = webClient.getPage(url);
HtmlForm loginForm = page.getFormByName("regform");


HtmlInput username = loginForm.getInputByName("txt_userid");
HtmlInput password = loginForm.getInputByName("txt_userpw");

username.setValueAttribute("username");
password.setValueAttribute("password");


HtmlSubmitInput submit = page.getHtmlElementById("login_btn");

webClient.waitForBackgroundJavaScript(30000);
HtmlPage result = submit.click();


FileWriter writer = new FileWriter("mofang.html");
writer.write(result.getWebResponse().getContentAsString());
writer.close();

最佳答案

webClient.waitForBackgroundJavaScript(30000);

之后

HtmlPage result = submit.click()

关于java - html单元 : An invalid or illegal selector was specified,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25236619/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com