Example 2: Extracting Data from HTML Tables

In this example, we'll demonstrate how to use BeautifulSoupOnline.com to extract data from HTML tables.

Steps:

  1. Visit the home.
  2. Paste the HTML code of the webpage containing the table you want to extract data from into the "Input HTML" field.
  3. Inspect the HTML structure of the webpage to identify the table element.
  4. Enter CSS selectors or XPath expressions in the "CSS Selector" field to target the table element.
  5. Click the "Parse" button to see the extracted data from the table.

Example:

Let's say you want to extract data from the following HTML table:

        
<table id="data-table">
    <thead>
      <tr>
        <th>Name</th>
        <th>Age</th>
        <th>City</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>John</td>
        <td>30</td>
        <td>New York</td>
      </tr>
      <tr>
        <td>Emily</td>
        <td>25</td>
        <td>Los Angeles</td>
      </tr>
    </tbody>
</table>
        
    

You can use the CSS selector "#data-table" to target this table element.

Now, paste the HTML code into the "Input HTML" field and enter "#data-table" into the "CSS Selector" field on BeautifulSoupOnline.com. Click "Parse" to see the extracted data from the table.