|
 |
|
ต้องการตัดหัวข้อออกเหลือแต่เนื้อหา รบกวนดู codeนี้หน่อยคับ |
|
 |
|
|
 |
 |
|
Code (PHP)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Silpakorn News Extraction</title>
</head>
<body>
<?php
include('C:\AppServ\simple_html_dom.php');
$urlWithoutProtocol = "http://su.ac.th/html_news/news_template.asp?id=5622";
$request = "";
$isRequestHeader = false;
// $dom = file_get_html(‘http://su.ac.th/html_news/news_template.asp?id=5622');
$exHeaderInfoArr = array();
$exHeaderInfoArr[] = "Content-type: text/xml";
$exHeaderInfoArr[] = "Authorization: "."Basic ".base64_encode("authen_user:authen_pwd");
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $urlWithoutProtocol);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
//curl_setopt($ch, CURLOPT_HEADER, (($isRequestHeader) ? 1 : 0));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// if( is_array($exHeaderInfo) && !empty($exHeaderInfo) )
//{
// curl_setopt($ch, CURLOPT_HTTPHEADER, $exHeaderInfo);
// }
$response = curl_exec($ch);
//curl_close($ch);
$html = str_get_html($response);
$elem = $html->find('table td.ms09', 0)->plaintext;
//echo file_get_html(‘http://su.ac.th/html_news/news_template.asp?id=5622/')->plaintext;
$textfile= "test1.txt";
$filew= fopen($textfile, 'w');
fwrite($filew, $elem);
fclose($filew);
echo $elem;
//echo $response;
?>
</body>
</html>
คืออยากตัดให้เหลือแต่เนื้อหา พอดีอันนี้มันมีหัวข้อมาด้วย ต้องทำไงคับ ขอบคุณคับ :)
Tag : PHP

|
|
 |
 |
 |
 |
Date :
2012-05-22 22:17:19 |
By :
ken |
View :
1922 |
Reply :
4 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
$html = file_get_html('http://su.ac.th/html_news/news_template.asp?id=5622');
$e = $html->find("td[class=ma09linespace]", 0);
echo $e->innertext;
|
 |
 |
 |
 |
Date :
2012-05-22 23:21:57 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากๆคับ
|
 |
 |
 |
 |
Date :
2012-05-22 23:58:42 |
By :
ken |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมนึกว่าผมโพสต์ไม่ไปนะนั่น เพราะเน็ตกากมาก มือถือเกือบเดี้ยงเลยครับ
กะว่าจะกลับมาโพสต์ให้ใหม่ ถ้าได้แล้วก็ดีแล้วครับ
|
 |
 |
 |
 |
Date :
2012-05-23 01:25:03 |
By :
deawx |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 02
|