1
我想从这个网站标题:http://feeds.foxnews.com/foxnews/latest如何使用Jaunt库从网站上抓取数据?
这样的例子:
<title><![CDATA[SUCCESSFUL INTERCEPT Pentagon confirms it shot down ICBM-type target]]></title>
,它会显示文字是这样的:
“成功拦截五角大楼证实其击落ICBM-类型目标 美国进行成功的导弹拦截试验,五角大楼说“
这是我的代码。我用过jaunt库。
我不知道为什么它显示的文字只有“foxnew.com”
import com.jaunt.JauntException;
import com.jaunt.UserAgent;
public class p8_1
{
public static void main(String[] args)
{
try
{
UserAgent userAgent = new UserAgent();
userAgent.visit("http://feeds.foxnews.com/foxnews/latest");
String title = userAgent.doc.findFirst
("<title><![CDATA[SUCCESSFUL INTERCEPT Pentagon confirms it shot down ICBM-type target]]></title>").getText();
System.out.println("\n " + title);
} catch (JauntException e)
{
System.err.println(e);
}
}
}
你可以尝试字符串title = userAgent.doc.findFirst( “
我试过了。输出是相同的显示文字只有“foxnew.com” 谢谢你:) – Puppet325