Skip to content

Jsoup Extension

Dmitriy Zayceff edited this page Apr 17, 2015 · 13 revisions

API: http://jphp-docs.readthedocs.org/en/latest/api_en/php/jsoup/

Jsoup is a library for working with real-world HTML. It provides a very convenient API for extracting and manipulating data, using the best of DOM, CSS, and jquery-like methods. It based on the jsoup java library jsoup.org

Usage

Getting and parsing text of url

use php\jsoup\Jsoup;

$doc = Jsoup::connect("http://en.wikipedia.org/").get();
$newsHeadlines = $doc->select("#mp-itn b a");

foreach ($newsHeadlines as $element) {
   echo "- {$element->text()}\n";
}

Clone this wiki locally