ยินดีต้อนรับคุณ, บุคคลทั่วไป กรุณา เข้าสู่ระบบ หรือ ลงทะเบียน

เข้าสู่ระบบด้วยชื่อผู้ใช้ รหัสผ่าน และระยะเวลาในเซสชั่น

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingช่วยหน่อยครับเรื่อง curl มันดึงข้อมูลมาไม่ครบ +1
หน้า: [1]   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ช่วยหน่อยครับเรื่อง curl มันดึงข้อมูลมาไม่ครบ +1  (อ่าน 689 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
WP-design
ก๊วนเสียว
*

พลังน้ำใจ: 32
ออฟไลน์ ออฟไลน์

กระทู้: 280



ดูรายละเอียด
« เมื่อ: 14 กรกฎาคม 2018, 10:14:08 »


โค๊ด:
<?php
$ch 
curl_init();
curl_setopt($chCURLOPT_URL,"https://sport.mthai.com/league-table/bundes-liga");
curl_setopt($chCURLOPT_FAILONERRORtrue);
curl_setopt($chCURLOPT_AUTOREFERERtrue);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_RETURNTRANSFER,true);
curl_setopt($chCURLOPT_TIMEOUT45);
$html_result curl_exec($ch);
curl_close($ch);
$dom = new DOMDocument();
@
$dom->loadHTML($html_result);
$xpath = new DOMXPath($dom);
$start_result strpos($html_result,'<div class="table-scroll">');
$end_result strpos($html_result,'</div>',$start_result);
echo 
substr($html_result,$start_result,$end_result-$start_result);

?>



ผมจะดึงตารางคะแนนจากเว็บ  https://sport.mthai.com/league-table/bundes-liga แต่แท็กปิด </div> มันไม่มาครับผมต้องแก้ยังไงครับ
มันมาเริ่มจาก <div class="table-scroll"> แต่แท็กปิด </div> มันหายไปครับ 






บันทึกการเข้า
amarin.ta
Newbie
*

พลังน้ำใจ: 0
ออฟไลน์ ออฟไลน์

กระทู้: 1



ดูรายละเอียด
« ตอบ #1 เมื่อ: 14 กรกฎาคม 2018, 15:18:03 »

ลองดูนะครับ

โค๊ด:
<?php
$ch 
curl_init();
curl_setopt($chCURLOPT_URL,"https://sport.mthai.com/league-table/bundes-liga");
curl_setopt($chCURLOPT_FAILONERRORtrue);
curl_setopt($chCURLOPT_AUTOREFERERtrue);
curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
curl_setopt($chCURLOPT_RETURNTRANSFER,true);
curl_setopt($chCURLOPT_TIMEOUT45);
$html_result curl_exec($ch);
curl_close($ch);


$html_result preg_replace("/[\n\r]/","",$html_result);
preg_match('/<div class="table-scroll">(?:.*?)<\/div>/m',$html_result,$match);
$divResult $match[0];
echo 
$divResult;

?>
บันทึกการเข้า
หน้า: [1]   ขึ้นบน
พิมพ์