无法识别JSoup发布请求错误

时间:2019-11-02 17:51:47

标签: java android performance android-asynctask jsoup

我正在尝试下载新表格https://www.keepoffline.com。为此,我正在使用Jsoup库。

 @Override
        protected Void doInBackground(Void... voids) {
            try {
                Document doc = Jsoup.connect("https://www.keepoffline.com")
                        .data("url", temp)
                        .post();
                Element p = doc.select("div.border-sec left-bdr").first();
                title = p.select("h2").first().text();
                Log.e("Main", title);
                Element link = doc.select("a.ajax-link-box").first();
                String atag = link.attr("href");
                matag = atag;
                Log.e("Main", matag);

            } catch (Exception e) {
                e.printStackTrace();
            }
            return null;
        }

我想要480p的画质,但它无法正常工作,只是重新启动。而且logcat中有错误。我不明白这个错误。非常感谢您的帮助

@Override
        protected void onPostExecute(Void aVoid) {
            View loadingIndicator = findViewById(R.id.loading_indicator);
            loadingIndicator.setVisibility(View.GONE);
            TextView t = (TextView) findViewById(R.id.genlink);
            t.setText(title);
            Button b = (Button) findViewById(R.id.fbdload);
            b.setVisibility(View.VISIBLE);
            b.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    DownloadManager dm = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
                    Uri uri = Uri.parse(matag);
                    DownloadManager.Request req = new DownloadManager.Request(uri);
                    req.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
                    String filename = title;
                    filename += ".mp4";
                    req.setDestinationInExternalPublicDir("/VideoDownloader", filename);
                    StyleableToast.makeText(getBaseContext(), "Download Started", Toast.LENGTH_SHORT, R.style.mytoast).show();
                    Long ref = dm.enqueue(req);
                }
            });
        }

0 个答案:

没有答案
相关问题