Extract the specified section of HTML from the DOM element

I am attempting to extract a specific CSS class from my DOM object using the simplehtmldom library.

1) The library

simplehtmldom.sourceforge.net

2) Since my localhost does not support fopen for some reason, I am utilizing the CURL library to retrieve the HTML. Here is the source:

3) At present, my script appears as follows. It fetches the HTML source from the desired website.

<?php
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, "http://hokejbal.cz/1-liga/tabulky/");
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    $result = curl_exec($curl);
    curl_close($curl);
    print $result;

    str_get_dom;
    $ret = $html->find('.standings tablesort tablesorter tablesorter-default');
?>

4) My goal now is to extract only a section of the website. Specifically, this table:

<table class="standings tablesort tablesorter tablesorter-default">

I identified it in the Google Chrome webmaster tools.

Regrettably, when I execute the script, I receive the entire HTML page instead of just the targeted portion. What could be the issue?

Answer №1

The correct selector to use is

'.standings.tablesort.tablesorter.tablesorter-default'

Update: Please see the updated code below.

<?php
    $html = file_get_html('http://hokejbal.cz/1-liga/tabulky/');  
    $ret = $html->find('table.standings', 0);
    print $ret;
?>

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

Having trouble with the overflow-x function in Wordpress Twenty Thirteen theme?

Currently, I am facing an issue while trying to insert code into one of my blog posts. To maintain the formatting, I decided to enclose the code within <pre> tags. However, due to Twenty Thirteen's fixed width template, the <pre> tags get ...

Showing Variables in JavaScript

<!DOCTYPE HTML> <html> <body> <button onclick="question++">Increment</button> <script> function test() { var question = 0; } </script> </body> </html> Qu ...

Is there a way to use the same color picker tool for adjusting both the background and text colors simultaneously?

My goal is to create functionality where the user can change the background color by clicking on the background of the div, and change text color by clicking on the text within the div. var box1 = document.querySelectorAll('.color1'); var pic ...

How can I customize the color of the Title Component in Ant Design using Styled Components?

I am currently integrating Ant Design with styled components in my project. One of the components in my application is a NavBar that includes an H1 Component. H1.tsx import React from 'react'; import { Typography } from 'antd'; impor ...

html table layout disrupted due to immovable column

I am facing a challenge in creating a table where the first column is fixed while the rest of the columns are scrollable horizontally. Although I was able to implement this successfully, it does not seem to work when integrated into my website. Whenever ...

Fetch operates based on the specified categoryId

Hey there, I'm currently in the process of learning JS and trying to fetch data from an API. I've successfully fetched all the work from api/works and displayed them in a div. Now, I'm looking to create 3 buttons that represent 3 categories ...

Display different website content in a div when the page loads

My current project involves creating a team website hosted on a LAMP server. This website includes various "team pages" dedicated to different age groups. I am facing the challenge of integrating "external" content (from another page within my domain) into ...

Eliminate the horizontal divider from the webpage, excluding the footer section

I'm currently utilizing the bootstrap framework to craft a responsive website. However, I've encountered an issue with a persistent horizontal bar at the bottom of the page that I can't seem to remove. After researching similar queries on st ...

Invisible and Unrestricted automatic playback

Why is auto play muted in both Firefox and Chrome? How can we code it so that browsers don't block it? Here's the code I'm using: <audio id="audio1" src="https://notificationsounds.com/storage/sounds/file-sounds-1217-relax ...

What is the best way to load my CSS file using express.static?

How do I properly load my CSS file using express.static in Node.js? I have attempted various methods to link my stylesheet to my HTML file through Express, and I'm also interested in learning how to include images, JavaScript, and other assets to crea ...

Creating a unique pattern in HTML5 to properly format phone numbers

<input type="text" pattern=" "> Is there a way to format this pattern to meet the following requirements? Guidelines: The first number must always be zero Only numbers and spaces are allowed Exactly 11 or 12 characters are permitted (including sp ...

When adding a new div, ensure it is counted and delete it once a new div is added

When clicked, a new div is added. When clicked again, another div with the same content is created as a duplicate. Q: Is there a way to remove the previous div when a new one is created? $(document).on('click', '.LibSectOpen', functio ...

Isotope grid shatters when browser window is resized

My goal is to design a 3-column grid using Twitter Bootstrap and Isotope. However, when I resize the browser to force the layout into a single column mode, Isotope fails and leaves large spaces both vertically and horizontally. Regular Layout Issues in ...

Retrieve information from data properties in the Froala editor

I'm currently developing a custom toolbar button for Froala Editor. To execute my desired action, I require access to a data attribute stored within the original textarea. Is there a recommended method for accomplishing this task? Appreciate your as ...

Use jQuery to easily update the background of an iFrame

I have implemented this code to store the background image selected from a dropdown menu labeled rds. This function also sets a cookie so that the chosen background persists even after the page is reloaded. The issue lies in the line containing $('da ...

Optimizing HTML5 metatags and styles for a mobile application

As a C++ developer who has recently delved into using HTML5 for my mobile applications, I am in need of guidance when it comes to fine-tuning my meta tags. While I do have some knowledge in web programming, there are still gaps in my understanding. I am s ...

Attempting to implement a functionality that will allow users to easily delete records from the database

I've taken on a school project where I am tasked with creating a login/registration form. Additionally, I need to develop functionality that allows users to register, login, view records, and delete records from the database using a dropdown menu and ...

Align two images to the center while displaying them in individual rows

<div class="client-logo-wrapper"> <a href="some link"><img class="client-logo" src="images/logo.png" alt="client-logo"></a> <a href="some link"><img class="contract-logo" src="images/logo.png" alt="contr ...

Setting a background image for your Ionic page

I am relatively new to using Ionic and I'm currently working on setting up a gradient image as the background for the welcome page of my app. While I've been successful in loading images from the assets/imgs folder on other pages, I'm facing ...

Interactive Typescript slider with drag functionality

Seeking assistance in developing a draggable slider using TypeScript. I have managed to retrieve the client and scroll positions, but I am struggling to change the ref scrollLeft position. There are no errors thrown; however, the ref's scrollLeft prop ...