พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
Moderator: mindphp, ผู้ดูแลกระดาน
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
ไม่ทราบว่าพอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
แบบว่าถ้าเราจะบันทึกหน้านั้นไว้ครับ คล้ายๆ กับ save as ที่จะได้ไฟล์เป็น .html และรูปไม่ทราบว่าพอมีแนวทางไหมครับ
แบบว่าถ้าเราจะบันทึกหน้านั้นไว้ครับ คล้ายๆ กับ save as ที่จะได้ไฟล์เป็น .html และรูปไม่ทราบว่าพอมีแนวทางไหมครับ
- secivon
- PHP Full Member
- โพสต์: 35
- ลงทะเบียนเมื่อ: 24/03/2009 5:15 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
ลอง file_get_contents() กับ fopen() ดูครับ
เหมือนจะต้องดูด้วยนะครับว่า server อนุญาตให้ allow_url_fopen หรือเปล่า
เหมือนจะต้องดูด้วยนะครับว่า server อนุญาตให้ allow_url_fopen หรือเปล่า
"อย่าเอาแต่โทษเด็ก ถ้าเด็กมันจะห่วย ดูตัวเองบ้างว่าทำบ้านเมืองไว้เป็นยังไง"
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
ช่วยขยายความหน่อยได้ไหมครับ คือผมมือใหม่ครับ อยากทราบแบบว่า รู็ URL แล้วบันทึกเป็น text
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
<?php
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
$homepage ตัวแปรนี้มันจะอยู๋ในรูปแบบของอะไรครับ คือผมจะเอาลง ฐานข้อมูล หรือ ว่าต้องทำให้อยู๋ในรูปแบบ text file ก่อน เพื่อเอา code มัน
$homepage = file_get_contents('http://www.example.com/');
echo $homepage;
?>
$homepage ตัวแปรนี้มันจะอยู๋ในรูปแบบของอะไรครับ คือผมจะเอาลง ฐานข้อมูล หรือ ว่าต้องทำให้อยู๋ในรูปแบบ text file ก่อน เพื่อเอา code มัน
- secivon
- PHP Full Member
- โพสต์: 35
- ลงทะเบียนเมื่อ: 24/03/2009 5:15 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
ดู manual link ก็น่าจะรู้แล้วนี่ครับว่าเป็น stringstring file_get_contents ( string $filename [, int $flags= 0 [, resource $context [, int $offset= -1 [, int $maxlen= -1 ]]]] )
แนะนำตัว debug function ที่ดีกว่า echo คือ var_dump($homepage) เพราะมันไฉไล เป็นอะไรก็ออกมาหมด
string เมื่ออยู่ใน variable ก็เป็น variable ครับคือผมจะเอาลง ฐานข้อมูล หรือ ว่าต้องทำให้อยู๋ในรูปแบบ text file ก่อน เพื่อเอา code มัน
ถ้าเอาไป write ลง File มันถึงจะเป็น text file
ถ้าเก็บลง database อย่างเดียว ก็ไม่มีความจำเป็นต้อง write ลงไฟล์ครับ mysql_real_escape_string() แล้วใช้ใน INSERT query ได้เลย
"อย่าเอาแต่โทษเด็ก ถ้าเด็กมันจะห่วย ดูตัวเองบ้างว่าทำบ้านเมืองไว้เป็นยังไง"
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
ขอบคุณมากเลบครับ บันทึกลงได้แล้วครับ ยังๆงช่วย ตอบปัญหาของผมทุกปัญหาหน่อยนะครับ จะเป็นพระคุณอย่างสุง
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
ผมเจอปัญหาแล้ว http://www.manager.co.th/Crime/ViewNews ... 0000037132
จากที่จะบันทึกข้อความบนหน้าเว็บจาก url นี้ พอดีว่า มันอ่านได้ไม่ครบครับ
มันบันทึกได้แค่นี้เอง ชนิดข้อมูลที่เบส LONGTEXT แต่ที่ลองผมลองก็อบโค้ด html จากวิวดูโค้ดมาใส่มันก็ใส่ได้ไม่ทราบว่าเกิดจากอะไรครับ
<html>
<head>
<title>Politics - Manager Online</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<META NAME="ROBOTS" CONTENT="NOARCHIVE">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link rel="stylesheet" title="Mocked" href="/css/css.css" type="text/css" disable>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Common.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Cookies.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Style.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Member.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Image.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/WebTools.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Comment.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
InitStyle();
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function Init()
{
MM_preloadImages('/images/SmallCssSelected.gif','/images/NormalCssSelected.gif','/images/LargeCssSelected.gif','/images/ExtraLargeCssSelected.gif');
}
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="Init();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="9" align="left" valign="top"><img src="images/head01.gif" width="9" height="13" border="0"></td>
<td align="left" valign="top" background="images/head02.gif"><img src="/images/blank.gif" width="221" height="13" border="0"></td>
<td width="20" align="left" valign="top" background="images/head04.gif"><img src="images/head03.gif" width="20" height="13" border="0"></td>
<td align="center" valign="top" background="images/head04.gif"><img src="/images/blank.gif" width="510" height="13" border="0"></td>
<td width="10" align="right" valign="top"><img src="images/head05.gif" width="10" height="13" border="0"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" background="/images/bghead.gif" width="37%" align="left"><img src="images/logo.gif" border="0"></td>
<td valign="top" background="/images/bghead.gif" align="center"><table width="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="frmSearch" action="ViewBrowse.aspx" target="_blank">
<tr>
<td width="8%" align="left" valign="middle" background="/images/bghead2.gif"><img src="/images/search.gif" width="66" height="29" border="0"></td>
<td width="77%" align="center" valign="middle" background="/images/bghead2.gif"><input type="text" name="Keyword" size="30" value="">
<select name="DayBackSearch">
<option value="1">
จากที่จะบันทึกข้อความบนหน้าเว็บจาก url นี้ พอดีว่า มันอ่านได้ไม่ครบครับ
มันบันทึกได้แค่นี้เอง ชนิดข้อมูลที่เบส LONGTEXT แต่ที่ลองผมลองก็อบโค้ด html จากวิวดูโค้ดมาใส่มันก็ใส่ได้ไม่ทราบว่าเกิดจากอะไรครับ
<html>
<head>
<title>Politics - Manager Online</title>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<META NAME="ROBOTS" CONTENT="NOARCHIVE">
<meta http-equiv="Content-Type" content="text/html; charset=windows-874">
<link rel="stylesheet" title="Mocked" href="/css/css.css" type="text/css" disable>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Common.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Cookies.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Style.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Member.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Image.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/WebTools.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" SRC="/JavaScript/Comment.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
InitStyle();
</SCRIPT>
<SCRIPT LANGUAGE="JavaScript">
function Init()
{
MM_preloadImages('/images/SmallCssSelected.gif','/images/NormalCssSelected.gif','/images/LargeCssSelected.gif','/images/ExtraLargeCssSelected.gif');
}
</SCRIPT>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="Init();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"> <table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="9" align="left" valign="top"><img src="images/head01.gif" width="9" height="13" border="0"></td>
<td align="left" valign="top" background="images/head02.gif"><img src="/images/blank.gif" width="221" height="13" border="0"></td>
<td width="20" align="left" valign="top" background="images/head04.gif"><img src="images/head03.gif" width="20" height="13" border="0"></td>
<td align="center" valign="top" background="images/head04.gif"><img src="/images/blank.gif" width="510" height="13" border="0"></td>
<td width="10" align="right" valign="top"><img src="images/head05.gif" width="10" height="13" border="0"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" background="/images/bghead.gif" width="37%" align="left"><img src="images/logo.gif" border="0"></td>
<td valign="top" background="/images/bghead.gif" align="center"><table width="80%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top"></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<form name="frmSearch" action="ViewBrowse.aspx" target="_blank">
<tr>
<td width="8%" align="left" valign="middle" background="/images/bghead2.gif"><img src="/images/search.gif" width="66" height="29" border="0"></td>
<td width="77%" align="center" valign="middle" background="/images/bghead2.gif"><input type="text" name="Keyword" size="30" value="">
<select name="DayBackSearch">
<option value="1">
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
<?php
require "connect_dbrss.php";
$file = 'http://www.manager.co.th/Politics/ViewN ... 0000037202';
$current = file_get_contents($file);
echo $current; //ตรงนี้มันสามารถ แสดงผลออกมาเป็นเว็บได้แต่
mysql_select_db($database_service, $db);
$sql= "INSERT INTO page (news) VALUES ('".mysql_real_escape_string($current))."')"; //พอเอาลง db มันใส่ข้อมูลให้ไม่ครบ
$ResultInsert= mysql_query($sql, $db) or die(mysql_error());
?>
เกิดจากอะไรครับ
require "connect_dbrss.php";
$file = 'http://www.manager.co.th/Politics/ViewN ... 0000037202';
$current = file_get_contents($file);
echo $current; //ตรงนี้มันสามารถ แสดงผลออกมาเป็นเว็บได้แต่
mysql_select_db($database_service, $db);
$sql= "INSERT INTO page (news) VALUES ('".mysql_real_escape_string($current))."')"; //พอเอาลง db มันใส่ข้อมูลให้ไม่ครบ
$ResultInsert= mysql_query($sql, $db) or die(mysql_error());
?>
เกิดจากอะไรครับ
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
จากที่ผมลอง เหมือนมันจะติด javascript ที่มันจะขึ้นมาตอนเราดู เหมือนตอนบันทึกลงฐานข้อมูลมันจะ อ่านถถึงแค่นั้นเลยทำให้ได้ข้อมูลไม่ครบ ไม่ทราบว่าจะแก้ยังไขครับ ช่วยที
-
- PHP Full Member
- โพสต์: 48
- ลงทะเบียนเมื่อ: 05/02/2009 5:06 pm
Re: พอจะมีวิธีบันทึกข้อความบนหน้าเว็บจาก url ได้ไหมครับ
อีกปัญหาก็คือว่า ภาษา UTF-8 กับ TIS-620 ของแต่ละ page ไม่เหมือนกัน เวลาคอนเนคดาต้าเบส ถ้าเซตให้เป้นแบบไหนแบบหนึ่ง ตัวหนังสืออีกแบบก็จะอ่านลงฐานข้อมูลไม่ได้ไม่ทราบว่าจะทำยังไง ช่วยหน่อยครับ
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: Baidu [Spider] และบุคลทั่วไป 132