Click here to Skip to main content
15,903,779 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Can anyone help me to how to check if a string is present in a web page and throw an output?

What I have tried:

protected Void doInBackground(Void... params) {
            try {
                doc = Jsoup.connect(url).get();
                linksOnPage = doc.select("h2.filmibeat-myshow-movie > a[href][title]");
            }
            catch (Exception e){e.printStackTrace();}
            return null;
        }

        @Override
        protected void onPostExecute(Void aVoid) {
            //Log.e("Value", txt);
            for(Element link : linksOnPage) {
                //Log.e("fsdsd", link.attr("title"));
                if (link.attr("title").contains(txt)) {
                    final Toast toast = Toast.makeText(MainActivity.this,"YO",Toast.LENGTH_SHORT);
                    toast.show();
                    Handler handler = new Handler();
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            toast.cancel();
                        }
                    },1000);

                }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900