Web解析器问题

时间:2013-01-16 17:03:27

标签: html parsing jsoup

我是Java的新手,所以我为此缺乏大量的主题而道歉。我正在尝试编写一个html解析器,它分析并返回来自此URL的元素中的数据:http://en.wikipedia.org/wiki/Neurons

运行程序时,我不断收到此错误消息:

Exception in thread "main" java.io.FileNotFoundException: src/product.txt`: (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:120)
    at org.jsoup.helper.DataUtil.load(DataUtil.java:36)
    at org.jsoup.Jsoup.parse(Jsoup.java:88)
    at ParserPractice2.main(ParserPractice2.java:16)

我目前的代码如下:

import java.io.File;
import java.io.IOException;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.parser.*;
public class ParserPractice2 {

    public static void main(String[] args) throws IOException {

        File input = new File ("src/product.txt`:");

        Document doc = Jsoup.parse(input, "UTF-8", "http://en.wikipedia.org/wiki/Neurons");

        Element content = doc.getElementById("bodyContent");
    }}*

Any help/feedback would be greatly appreciated by this noobie =)Thanks!

1 个答案:

答案 0 :(得分:1)

此文件不存在:

new File ("src/product.txt`:");

也许你的意思是"src/product.txt"