kris@sentientgeeks.com 01ed2f0b15 initial Commit
2021-02-09 10:26:46 +05:30

136 lines
3.4 KiB
PHP

<?php
function milesplit($url)
{
ini_set('max_execution_time', 0);
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($response);
libxml_clear_errors();
$xpath = new DOMXpath($dom);
$values = array();
$row = $xpath->query('//div[@id="meetResultsBody"]/pre');
foreach($row as $value) {
$values[] = trim($value->textContent);
}
return $values[0];
}
function just_time_in_racing($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($response);
libxml_clear_errors();
$xpath = new DOMXpath($dom);
$values = array();
$row = $xpath->query('//body/pre');
foreach($row as $value) {
$values[] = trim($value->textContent);
}
return @$values[0];
}
function mysplitdrilldrowncase($url)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($response);
libxml_clear_errors();
$xpath = new DOMXpath($dom);
$values = array();
$row = $xpath->query('//table[contains(@class,"meetResultsList")]/tbody/tr/td/a/@href');
foreach($row as $value) {
$values[] = milesplit('https://ny.milesplit.com'.str_replace('auto','raw',trim($value->textContent)));
}
$body=implode(chr(13).chr(13).chr(13), $values);
$html='';
$html .= "Licensed to ".forHeader($url,'//div[contains(@class,"hostedBy")]/a').chr(13);
$html .=" ".forHeader($url,'//h1[contains(@class,"meetName")]').chr(13);
$html .=" ".forHeader($url,'//div[contains(@class,"venueName")]').chr(13);
$html .="Results".chr(13).chr(13);
$html .=$body;
return $html;
}
function forHeader($url,$parseHtml)
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$response = curl_exec($curl);
$dom = new DOMDocument();
libxml_use_internal_errors(true);
$dom->loadHTML($response);
libxml_clear_errors();
$xpath = new DOMXpath($dom);
$values = array();
$row = $xpath->query($parseHtml);
foreach($row as $value) {
$values[] = trim($value->textContent);
}
return @$values[0];
}
?>