[英]Extract comments using Jsoup
I am trying to extract comments and found this code here...I am running this through Netbeans...When i ran this code it is throwing an error... 我试图提取注释并在这里找到此代码...我正在通过Netbeans运行它...当我运行此代码时它抛出了错误...
import org.jsoup.Jsoup;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.jsoup.nodes.Document;
public class Main {
public static void main(String[] args) {
Document doc = Jsoup.connect("http://www.zomato.com/mumbai/starbucks-coffee-fort").get();
Elements div = doc.select("div.res-review-body > div > p");
for (Element paragraph : div) {
System.out.println(paragraph.text());
}
}
}
Error Details: 错误详情:
java:15: unreported exception java.io.IOException; java:15:未报告的异常java.io.IOException; must be caught or declared to be thrown Document doc = Jsoup.connect(" http://www.zomato.com/mumbai/starbucks-coffee-fort ").get();
必须被捕获或声明为抛出Document doc = Jsoup.connect(“ http://www.zomato.com/mumbai/starbucks-coffee-fort ”).get();
If you are using Netbeans you will be certainly able to see a red color light bulb in front of this line. 如果您使用的是Netbeans,您肯定会在此行的前面看到一个红色的灯泡。
Document doc = Jsoup.connect("http://www.zomato.com/mumbai/starbucks-coffee-fort").get();
click that bulb and it will show you the options. 单击该灯泡,它将显示您的选项。 What you are missing is a try catch block for java.io.IOException.
您缺少的是java.io.IOException的try catch块。
Edit: - By clicking on that bulb it will give you option to surround the block with try and catch. 编辑:-通过单击该灯泡,它将为您提供尝试和围住包围块的选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.