【问题标题】:Jason 'select' not working in android StudioJason 'select' 在 android Studio 中不起作用
【发布时间】:2021-06-10 18:14:11
【问题描述】:

这是我的 .java 文件:

我将 Jsoup 添加到依赖项中,但仍然无法访问函数“select”。错误说 无法解析“文档”中的方法“选择”

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parsing);
}
private class Content extends AsyncTask<Void,Void,Void>
{
    @Override
    protected Void doInBackground(Void... voids) {
        try {
            Document document= (Document) Jsoup.connect("https://www.dsebd.org/latest_share_price_scroll_by_value.php").get();
            document.select("table.table-bordered.background-white.shares-table.fixedHeader");

        }catch (Exception e)
        {
            Toast.makeText(Parsing.this,""+e,Toast.LENGTH_SHORT).show();
        }
        return null;
    }
}
}




dependencies {

implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-auth:21.0.1'
implementation 'org.jetbrains:annotations:15.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testImplementation 'junit:junit:4.+'
implementation 'org.jsoup:jsoup:1.13.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}

【问题讨论】:

    标签: java android json jsoup


    【解决方案1】:

    好的,我想我解决了这个问题。

    并且 Document 声明必须是 com.jsoup.nodes

    的类型

    代码需要在jsoup.connect行后面加上这个

    Elements elements= document.select("table.table-bordered.background-white.shares-table.fixedHeader");
    

    【讨论】:

      猜你喜欢
      • 2018-06-18
      • 2017-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-25
      • 1970-01-01
      • 2016-04-28
      • 2021-12-16
      相关资源
      最近更新 更多