0
如果有人输入!音乐,我正在写一个应该从此网页抓取艺术家姓名的IRC机器人http://whatthefuckshouldilistentorightnow.com/artist.php?artist=e&x=36&y=30。这是代码的一部分:Jsoup符号错误
public void onMessage(String channel, String sender, String login, String hostname, String message) {
if (messageIC.startsWith("!music ")) {
String musicy = "id=\"artist\">"
try {
Document doc = Jsoup.connect("http://whatthefuckshouldilistentorightnow.com/artist.php?artist=e&x=36&y=30").get();
}
catch (IOException e){
}
String texty = doc.body().text(); // "An example link"
if (texty.contains(musicy)) {
String artisty = texty.substring(musicy);
int artsy1 = artisty.indexOf(">") + 1;
int artsy2 = artisty.indexOf("</div>");
artisty = artisty.substring(artsy1, artsy2);
sendMessage(channel, "artisty: " + artisty); // */
}
else {
sendMessage(channel, "Something went wrong.");
}
}
}
但是,我收到String texty = doc.body()。text();.该消息是:
“找不到符号
符号:方法体()”
任何想法,什么是错的还是如何提高代码将不胜感激。
我试过了,我仍然在doc.body()。text()接收到一个错误。 – quibblify
您是否尝试过符合条件的'Document'来确保您引用的是JSoup类而不是另一个'Document'类? (也可以像@Amir Raminfar所说的那样从'try'子句中取出声明) – theduck