Retrieve the HTML content from a WebView

Is there a way to extract only the Table (TagName: tbody) from a specific webpage? The link to the webpage is here:

I've been following a tutorial on how to do this at , but I'm running into some issues. Can anyone provide assistance?

Here's the code snippet that I've tried:

public class Stundenplan extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final Context myApp = this; 
    class MyJavaScriptInterface  
    {  
        @SuppressWarnings("unused")  
        public void showHTML(String html)  
        {  
            new AlertDialog.Builder(myApp)  
                .setTitle("HTML")  
                .setMessage(html)  
                .setPositiveButton(android.R.string.ok, null)  
            .setCancelable(false)  
            .create()  
            .show();  
        }  
    }  

    final WebView browser = (WebView)findViewById(R.id.webView);  
    browser.getSettings().setJavaScriptEnabled(true);  
    browser.addJavascriptInterface(new MyJavaScriptInterface(), "HTMLOUT");  
    browser.setWebViewClient(new WebViewClient() {  
        @Override  
        public void onPageFinished(WebView view, String url)  
        {  
            browser.loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('tbody')[0].innerHTML+'</head>');");  
        }  
    });  

    browser.loadUrl("http://info.tam.ch/custom/stpl_klw.php"); 
}

Answer №1

Upon inspection, it was found that the HTML code of the specified webpage does not include a <tbody> tag. Instead, the schedule is displayed using a standard <table> element.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Automatically update Android applications when newer versions become available in API levels 24 and 25 through programming

I've been attempting to update my app on Nougat, but I keep encountering the following error: code File f = new File(String.valueOf(uri)); Uri myURI= FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", ...

Please provide a text file containing rows of numbers as input

Hey there, I'm encountering an issue with a text file that contains numbers in multiple rows. The error message I'm getting is: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 I've checked ...

Retrieve the 90 days leading up to the current date using JavaScript

I've been searching for a way to create an array of the 90 days before today, but I haven't found a solution on StackOverflow or Google. const now = new Date(); const daysBefore = now.setDate(priorDate.getDate() - 90); The result I'm looki ...

Tutorial: Using Three.js to Assign a Unique Random Image to Each Side of Multiple Cubes

I am currently working on integrating a feature similar to the one demonstrated in this example: While I have successfully implemented cubes, I am facing a challenge in applying different images to each cube. My goal is to assign a "Blogger" icon to one ...

What is the best approach to testing a function that relies on a reference to Firebase?

I am currently trying to write unit tests for a function within my application that interacts with Firebase, specifically by calling and updating a reference. However, I have encountered an issue while attempting to run the test - upon importing the file c ...

Distinguishing between resolving a promise in a service/factory as opposed to in a controller within AngularJS

After experimenting with resolving a promise in both a service and a controller, I have found that I prefer to resolve it in the service so that I can reuse the variable without having to resolve it multiple times. However, I am encountering an issue where ...

Executing Selenium tests in parallel with TestNG and skipping or disabling specific tests based on parameters passed through Maven command line

We operate a multinational website where not all features are available in every country due to different languages. Currently, we have hundreds of tests built on the Java stack - including TestNG listeners, Selenium WebDriver (following the Page Object Mo ...

Unable to access and process POST parameters sent via ajax in PHP

When passing two parameters in the send method to index.php, an error "Undefined index" is returned by PHP. echo $_POST['fname']; submit.addEventListener("click", function(e){ e.preventDefault(); var xhr = new XMLHttpRequest(); xhr. ...

Ways to extract the portion of a string that lies between two instances of ":"

If I have a string similar to this: "(...) Example: Hello world. Description: Here is a long text, with words and punctuation. This is the part I need. This part I do not need: End of the example. (...)" How can I extract only this part: Here is ...

Encountering an error with Gatsby while running the development environment due to issues with antd and less configuration (NPM

Encountering issues with the development server in local after installing antd, less, less-loader, gatsby-plugin-less, and gatsby-plugin-antd Versions: "gatsby-plugin-less": "^6.20.0", "less": "^2.7.1", "less- ...

Switching the language with just a click of a button in an android application

Currently facing an issue with switching languages in my app. I am looking for a way to instantly switch the language when a button is clicked. I have two buttons, one for French (FR) and the other for English (ENG). Initially, I thought about using a dif ...

Skipping the validation of a variable in a return statement with Angular and Javascript

Is there a way to exclude level a.3 from the return in the completion form if a.3 is undefined? scope.isValid = function() { return a.1 && a.2 && a.3; }; ng-disabled="!isValid()" ...

What is the best way to eliminate the default hover effect using the MenuItem Mui class?

My goal is to eliminate the default gray hover over animation when using the MUI menu item class. I have attempted several methods, but none have been successful so far. Here are a couple of examples: <MenuItem divider sx={{'&:hover':{bac ...

What is the best way to send push notifications to all users when new data is added to the database?

"I'm new to databases and currently using MySQL. Do I need to switch to the Firebase realtime database? Could you provide me with tutorials or code snippets? I find Java language difficult to understand." ...

What could be the reason for the lack of support for bi-directional relations in Hibernate when using H

The Query What causes the difference in behavior between Hibernate with H2 and Hibernate with MySQL? Our setup involves using Hibernate as the Object-Relational Mapping (ORM) tool. In the production system, we rely on a MySQL database along with LiquiBas ...

How to play two audio files at the same time on iOS Safari

I encountered a unique challenge in Javascript when attempting to play two audio files simultaneously on iOS Safari. One file is the voice script, while the other serves as background sound playing on loop. The code snippet I utilized for this task is as f ...

Using a combination of Vue.js, Flask, and AWS Cognito for seamless authentication

Currently delving into the realm of Vue JS, I have grasped the concept of Vue JS <-> AWS Cognito authentication process and the integration of Vue JS <-> Flask. I am now curious to explore how to authenticate a user using AWS Cognito with Vue J ...

React custom slider component is failing to meet expectations

I've been working on enhancing my React skills and building my portfolio. Instead of using a library, I opted to create a custom slider using the code below: const ProjectWrapper = styled.div` .container { transform: translateX(-$ ...

Exploring the Benefits of Using AJAX with Single or Multiple JavaScript Files

Here's a question for best practices. I'm working on building an AJAX application where the main page loads everything through AJAX into the content section. Should I merge all my javascript files into one that is loaded on the main page, or spli ...

Challenge with Transferring Data to be Displayed

My issue lies in calling a function with 3 inputs - 2 numbers and 1 string. The two numbers are being passed correctly, but I need the string to be printed within the element. I suspect the problem is related to passing the parameter to an HTML part of th ...