Skip to content

Instantly share code, notes, and snippets.

@jonigl
jonigl / simplest-scraper.php
Created July 26, 2016 20:55
Simplest scraper
<?php
$contents = file_get_contents("URL HERE");
$dom = new DOMDocument();
@$dom->loadHTML($contents);
$xpath = new DOMXpath($dom);
$element = trim((string) $xpath->query("XPATH FROM CHROME HERE")->item(0)->nodeValue);
echo $element;
?>
@jonigl
jonigl / scrap.php
Created July 26, 2016 20:08
PHP - scrap using xpath
<?php
$curl = curl_init('http://testing-ground.scraping.pro/blocks');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
if(curl_errno($curl)) // check for execution errors
{
echo 'Scraper error: ' . curl_error($curl);
exit;
}
curl_close($curl);
@jonigl
jonigl / Kaltura Player API
Created May 11, 2016 20:25
Also Playlists API
var playerId = 'myEmbedTarget';
kWidget.embed({
'targetId': playerId,
'wid': '_xxx',
'uiconf_id': 'xxxx',
'flashvars': {
'playlistAPI': {
'plugin': true,
'includeInLayout': false,
'autoPlay': true,