PHP Simple HTML DOM Parser
A fast, simple and reliable HTML document parser for PHP.
Created by S.C. Chen, based on HTML Parser for PHP 4 by Jose Solorzano.
Parse any HTML document
PHP Simple HTML DOM Parser handles any HTML document, even ones that are considered invalid by the HTML specification.
Select elements using CSS selectors
PHP Simple HTML DOM Parser supports CSS style selectors to navigate the DOM, similar to jQuery.
Download
- Download the latest version from SourceForge
Contributing
- Request features on the Feature Request Tracker
- Report bugs on the Bug Tracker
- Get involved with the community on the Discussions Board
License
PHP Simple HTML DOM Parser is Free Software licensed under the MIT License.
I'm having trouble figuring out how to use PHP Simple HTML DOM Parser for pulling information from a website.
require['simple_html_dom.php'];
$html = file_get_html['//example.com'];
$ret = array[];
foreach[$html->find[".project-card-mini-wrap"] as $element] {
echo $element;
}
The output of $element
is:
10 days to go
A clothing brand like never seen before
KOSTIREV - THE REAL YOU
This is the information I'd like to pull from the website:
1: Link
href
2: Image src
3: Project name
jaggedsoft
3,5871 gold badge32 silver badges40 bronze badges
asked Nov 20, 2015 at 8:14
3
Hopefully this will provide some insight to you as well as other users of PHP Simple HTML DOM Parser
foreach[$html->find[".project-card-mini-wrap"] as $element] {
echo "Project name: ",$element->find['.project_name',0]->innertext,"
\n";
echo "Image source: ",$element->find['img',0]->src,"
\n";
echo "Link: ",$element->find['a',0]->href,"
\n";
}
Produces this output:
Project name: KOSTIREV - THE REAL YOU
Image source: //ksr-ugc.imgix.net/projects/2123706/photo-original.png?v=1444253259&w=218&h=162&fit=crop&auto=format&q=92&s=9d6c437e96b720dce82fc9b598b3e8ae
Link: /projects/andrewkostirev/kostirev-the-real-you
answered Nov 20, 2015 at 8:23
jaggedsoftjaggedsoft
3,5871 gold badge32 silver badges40 bronze badges
2
I tried this and it worked, thanks for the help! Here is something i made using primewire.ag as a example.... The goal here was to extract all the links of a given page.
answered Feb 3, 2018 at 3:25