简体   繁体   English

不能在jsoup中使用Document

[英]Can't use Document in jsoup

I'm trying to use jsoup to parse HTML to my android app. 我正在尝试使用jsoup将HTML解析为我的Android应用程序。 but It seems the error occur at Document. 但似乎错误发生在Document。

"Document cannot be resolved to be a type" “文档无法解析为类型”

"Jsoup cannot be resolved" “Jsoup无法解决”

Could anyone help me solve this? 谁能帮我解决这个问题? because I've not found the way to solve it. 因为我找不到解决问题的方法。

import java.net.URL;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

URL url = new URL("http://google.com");
Document document = Jsoup.parse(url, 5000);

} }

"Jsoup cannot be resolved" “Jsoup无法解决”

Because you didn't import the library properly. 因为您没有正确导入库。 You have to make a lib folder put the .jar in the folder then, add the build path. 你必须创建一个lib文件夹,然后将.jar放在文件夹中,添加构建路径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM