Skip to content

Instantly share code, notes, and snippets.

@folmert
Last active August 29, 2015 14:22
Show Gist options
  • Save folmert/d9cb60d750bf3cf77eb6 to your computer and use it in GitHub Desktop.
Save folmert/d9cb60d750bf3cf77eb6 to your computer and use it in GitHub Desktop.
<?php
// Create a new cURL resource
$curl = curl_init();
if (!$curl) {
die("Couldn't initialize a cURL handle");
}
// Set the file URL to fetch through cURL
curl_setopt($curl, CURLOPT_URL, "http://newconnect.pl/?page=1045&id_firm=&id_tr=&ncc_index=ERN");
// Set a different user agent string (Googlebot)
curl_setopt($curl, CURLOPT_USERAGENT, 'Googlebot/2.1 (+http://www.google.com/bot.html)');
// Follow redirects, if any
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
// Fail the cURL request if response code = 400 (like 404 errors)
curl_setopt($curl, CURLOPT_FAILONERROR, true);
// Return the actual result of the curl result instead of success code
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Wait for 10 seconds to connect, set 0 to wait indefinitely
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
// Execute the cURL request for a maximum of 50 seconds
curl_setopt($curl, CURLOPT_TIMEOUT, 50);
// Do not check the SSL certificates
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
// Fetch the URL and save the content in $html variable
$html = curl_exec($curl);
// Check if any error has occurred
if (curl_errno($curl)) {
echo 'cURL error: ' . curl_error($curl);
}
else {
// cURL executed successfully
}
// close cURL resource to free up system resources
curl_close($curl);
include_once "./vendors/simple_html_dom/simple_html_dom.php";
$htmlDom = str_get_html($html);
$rowsEbi = [];
foreach ($htmlDom->find('.TabEBI',0)->find('tr') as $tr => $tr_val) {
array_push($rowsEbi, $tr_val);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment