我有这个问题......我想知道你们是否有任何想法如何解决它?
我必须将课程名称、教师姓名和教室分开。
Progr.al.Janek ManderÕ 405 Arv.võr.Tom KülaotsÕ 205
程序 是课程名称,Janek Mander 是教师名称,Õ 405 是教室。Arv.võr。是课程名称,Tom KÜlaots 是教师名称,Õ 205 是教室。
我必须将它们分开,以便我可以识别它们......可能进入数组
info[0] = "Progr.al."
info[1] = "Janek Mander"
info[2] = "Õ 405"
现在我有了这个想法...如果我可以检测到大写字母并用 #{uppercaseletter} 替换该字符串,那么我可以将其爆炸...Õ 405 我可以按 Õ 爆炸,因为每个教室前面都有一个 Õ。
好吧 Progrl.al.Janek ManderÕ 405...只有三个大写字母...老师的名字总是第二个大写字母...有什么办法可以利用它来提高我的优势还是我必须重写dom脚本?
到目前为止的整个代码...
<!doctype html>
<html>
<head>
<title>Ilus tunniplaan</title>
<style>
.tund
{
width: 140px;
width: 405px;
border: 1px solid black;
}
.
</style>
</head>
<body>
<?php
ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'Off');
ini_set('log_errors', 'Off');
function grab_page( $site )
{
$ch = curl_init( );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
curl_setopt( $ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT'] );
curl_setopt( $ch, CURLOPT_TIMEOUT, 40 );
curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" );
curl_setopt( $ch, CURLOPT_URL, $site );
ob_start( );
return curl_exec ( $ch );
ob_end_clean( );
curl_close ( $ch );
}
$html = grab_page( "http://web.ametikool.ee/tunniplaan/11.%20n%e4dal%2008.11%20-%2013.11/" );
$dom = new domDocument;
/*** load the html into the object ***/
$dom->loadHTML($html);
/*** the table by its tag name ***/
$tables = $dom->getElementsByTagName('table');
/*** get all rows from the table ***/
$rows = $tables->item(0)->getElementsByTagName('tr');
/*** loop over the table rows ***/
foreach ($rows as $row)
{
$id = $id + 1;
if( $id > 16 )
{
/*** get each column by tag name ***/
$cols = $row->getElementsByTagName('td');
/*** echo the values ***/
for ( $counter = 0; $counter <= 9; $counter += 1)
{
$phrase = $cols->item($counter)->nodeValue;
echo $phrase . "<br/>\n";
}
}
}
?>
</body>
</html>