ขอแนวทางเกี่ยวกับ Auto post หน่อยครับ ยินดีของแถมสมนาคุณเต็มที่

เริ่มโดย $100perday, 21 มกราคม 2013, 09:17:05

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

adjobb

PM เข้าดูไม่ได้ในนี้ละกันครับ

ของ mthai ยังไม่ค่อยลองแก้โค้ดดูครับ โค้ดที่เคยแกะคนอื่นมาก็ประมาณนี้ครับ อันนี้เป็นการดึงข่าวจาก ไทยรัฐ นะครับไม่ใช่เอ็มไทย แต่หลักการมันเหมือนๆกัน
ปล. ดึงลง wordpress นะครับลองเอาไปปรับดึงลง ฐานข้อมูลดูครับ

ผมตอบ PM ไม่ได้นะครับ ที่ส่ง ออเร่อมา โฮสน่าจะปิดฟังชั่น อะไรสักอย่าง....

config.php
<?php
/************************/
/* หมวดของการติดต่อฐานข้อมูล */
/**********************/
$host "mysql.main-hosting.com"//ใส่ชื้อโฮสของคุณเช่น  $host = 'localhost';
$root "u706496516_jeDaH"//ใส่ชื่อผู้ใช้เพื่อติดต่อฐานข้อมูลเช่น  $root = 'root';
$pass "XubySejasu"//ใส่รหัสผ่านเพื่อติดต่อฐานข้อมูลเช่น $pass = 'password';
$dtbn "u706496516_RyReN"//ใส่ชื่อฐานข้อมูล  WP ของคุณเช่น $dtbn = 'databasename';
$fix "wp_"//ใส่ชื่อนำหน้าฐานข้อมูล  WP ของคุณ
$wp_userid "1"//ใส่  WPUserID ของคุณโดยทั่วไปหากคุณเป็ฯผู้ดูและระบบ WPUserID จะเป็น 1 

/********************/
/* หมวดของการตั้งค่าระบบ */
/*******************/

$submitnew_ent "1";//หากต้องการดึงข่าวบันเทิงให้ใส่ค่าเป็น 1 หากไม่ต้องการให้ใส่เป็น 0
$wp_categoriesID_ent "4";//ใส่ categoriesID สำหรับข่าวบันเทิง

$objConnect mysql_connect($host,$root,$pass) or die("Error Connect to Database");
$objDB mysql_select_db($dtbn);
$cn = @mysql_connect($host,$root,$pass);
mysql_query("SET NAMES UTF8");

 
?>


ent.php
<?php

include("config.php");

$wp_categoriesID $wp_categoriesID_ent;
$submitnew $submitnew_ent;
$xml "http://www.thairath.co.th/rss/ent.xml";

include(
"submit.php");



submit.php
<?php

if($submitnew==1){
$filename $xml;
$dom = new DOMDocument();

if ($dom->load($filename)) {

$data $dom->getElementsByTagName("item");
foreach($data as $theData) {
$title =  trim($theData->getElementsByTagName("title")->item(0)->nodeValue);
$description =  trim($theData->getElementsByTagName("description")->item(0)->nodeValue);
$link =  trim($theData->getElementsByTagName("link")->item(0)->nodeValue);
$image =  trim($theData->getElementsByTagName("enclosure")->item(0)->getAttribute('url'));

$i=0;
$strSQL "SELECT * FROM ".$fix."posts WHERE post_content_filtered = '$link'";
$objQuery mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult mysql_fetch_array($objQuery)) {

$i=++$i;

}

if($i==0){
   
$contentdata=file_get_contents("$link"); 
$next_start=0
$start=strpos($contentdata,'<div id="details" class="page">',$next_start); 

if($next_start==0){

$end strpos($contentdata,'</p></p>',$start);
$content substr($contentdata,$start,($end-$start));
$next_start=1;       

}

$pos1 explode("<img src=\"",$content);
$content implode("<img src=\"http://www.thairath.co.th",$pos1);

$pos1 explode("th /media/",$content);
$content implode("th/media/",$pos1);

$pos1 explode("<div class=\"column-420 column-left\">",$content);
$content implode("",$pos1);

$pos1 explode("<div class=\"entry\">",$content);
$content implode("",$pos1);

$pos1 explode("<div id=\"details\" class=\"page\">",$content);
$content implode("",$pos1);

$pos1 explode(" alt=\"\" class=\"detail-image\" />",$content);
$content implode("",$pos1);

$content "$content</p></p>";

//echo '<a href="'.$link.'">'.$title."</a><br />";
//echo $content;     

$date date("Y-m-d");
$time date("H:i:s");
$alias  date("Y-m-d-H-i-s");
$ip $_SERVER["REMOTE_ADDR"];
$pos1 explode("'"$title);
$title implode("\'",$pos1);
$pos2 explode("'"$content);
$content implode("\'",$pos2);
$copy "<br> เนื้อหาจาก<a href=\"$link\" target =\"_blank\">หนังสือพิมพ์ไทยรัฐ</a>";
$content ="$content $copy";

$strSQL3 "INSERT INTO ".$fix."posts 
VALUES ('', '
$wp_userid', '$date $time', '$date $time', '$content', '$title','', 'publish', 'open', 'open',
'', '', '','','
$date $time','$date $time','$link','0',
'','0','post','','0')"
;
$objQuery3 mysql_query($strSQL3) or die ("Error Query [".$strSQL3."]");

$strSQL "SELECT * FROM ".$fix."posts WHERE post_content_filtered = '$link'";
$objQuery mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult mysql_fetch_array($objQuery)) {

$PostID =$objResult["ID"];

}

$strSQL33 "INSERT INTO ".$fix."term_relationships 
VALUES ('
$PostID', '$wp_categoriesID', '0')";
$objQuery33 mysql_query($strSQL33) or die ("Error Query [".$strSQL33."]");

$strSQL5"UPDATE ".$fix."term_taxonomy SET count =  count+1
   WHERE term_id  = '
$wp_categoriesID'";
$objQuery5 mysql_query($strSQL5) or die ("Error Query [".$strSQL5."]");



}

}
} else {
echo("This document is not valid!");
}
}

?>

adjobb

ที่บอกว่า error ทาง PM ตะกี้ลองแก้ให้ดูแล้วครับรันผ่าน... ใน localhost

<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html{
font:11px Arial, Helvetica, sans-serif; /* Sets the font size and type for the whole html page */
color:#333;} /* Sets the font color for the whole html page */

.menu{
margin:0 auto;
width: 1024px; /*กำหนดความกว้าง*/
background-color: #333;} /* กำหนดสีพื้นหลัง */

.menu ul{
margin: 0;
padding: 0;
float: left;}

.menu ul li{
display: inline;
float: left;
text-decoration: none; /* removes the underline from the menu text */
color: #fff; /* text color of the menu */
padding: 10.5px 11px; /* 10.5px of padding to the right and left of the link and 11px to the top and bottom */
background-color: #333;
width:260px;
} /* Makes the link all appear in one line, rather than on top of each other */


.menu ul li a{
float: left;
text-decoration: none; /* removes the underline from the menu text */
color: #fff; /* text color of the menu */
padding: 10.5px 11px; /* 10.5px of padding to the right and left of the link and 11px to the top and bottom */
background-color: #333;}

.menu ul li a:visited{ /* This bit just makes sure the text color doesn't change once you've visited a link */
color: #fff;
text-decoration: none;}

.menu ul li a:hover, .menu ul li .current{
color: #fff;
background-color:#0b75b2;} /* change the background color of the list item when you hover over it */
</style>


</head>

<body>
    <div class="menu">
        <ul>

<?
$xml5=file("http://wordpress.in.th/feed");

$xmlDATA="";
foreach($xml5 as $key=>$value){
$xmlDATA.=$value;
}
$data1=explode("<item>",$xmlDATA);
$iTitle=array();
$iLink=array();
$iDesc=array();
$content=array();

foreach($data1 as $key=>$value){
if($key>0 AND $key!=30){
echo "<li>";
$value=str_replace("</item>","",$value);
$iTitle[$key]=mb_substr(strip_tags(substr($value,strpos($value,"<title>"),strpos($value,"</title>"))),0,30,'UTF-8');
$content[$key]=substr($value,strpos($value,"<content:encoded>"),strpos($value,"</content:encoded>")); //<content:encoded>
$iLink[$key]=strip_tags(substr($value,strpos($value,"<link>"),strpos($value,"</link>")-strpos($value,"<link>")));
$iDesc[$key]=strip_tags(substr($value,strpos($value,"<description>"),strpos($value,"</description>")-strpos($value,"<description>")));
preg_match('/src="(.*?)"/', $content[$key], $matches);
//echo $matches[1]."<br>";
echo '<img src="'.$matches[1].'" width="300" height="250"><br>';
echo "<a href='".$iLink[$key]."' target='_blank' />".$iTitle[$key]."....</a><br/>";
//preg_match('/src="(.*?)"/', $content[$key], $matches);
//print_r($matches);

//print_r($matches);
echo "</li>\n";

}
}
?>
        </ul>
        <br style="clear: left" />
    </div>

</body>
</html>

$100perday

อ้างถึงจาก: adjobb ใน 22 มกราคม 2013, 01:18:07
ที่บอกว่า error ทาง PM ตะกี้ลองแก้ให้ดูแล้วครับรันผ่าน... ใน localhost

<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
html{
font:11px Arial, Helvetica, sans-serif; /* Sets the font size and type for the whole html page */
color:#333;} /* Sets the font color for the whole html page */

.menu{
margin:0 auto;
width: 1024px; /*กำหนดความกว้าง*/
background-color: #333;} /* กำหนดสีพื้นหลัง */

.menu ul{
margin: 0;
padding: 0;
float: left;}

.menu ul li{
display: inline;
float: left;
text-decoration: none; /* removes the underline from the menu text */
color: #fff; /* text color of the menu */
padding: 10.5px 11px; /* 10.5px of padding to the right and left of the link and 11px to the top and bottom */
background-color: #333;
width:260px;
} /* Makes the link all appear in one line, rather than on top of each other */


.menu ul li a{
float: left;
text-decoration: none; /* removes the underline from the menu text */
color: #fff; /* text color of the menu */
padding: 10.5px 11px; /* 10.5px of padding to the right and left of the link and 11px to the top and bottom */
background-color: #333;}

.menu ul li a:visited{ /* This bit just makes sure the text color doesn't change once you've visited a link */
color: #fff;
text-decoration: none;}

.menu ul li a:hover, .menu ul li .current{
color: #fff;
background-color:#0b75b2;} /* change the background color of the list item when you hover over it */
</style>


</head>

<body>
    <div class="menu">
        <ul>

<?
$xml5=file("http://wordpress.in.th/feed");

$xmlDATA="";
foreach($xml5 as $key=>$value){
$xmlDATA.=$value;
}
$data1=explode("<item>",$xmlDATA);
$iTitle=array();
$iLink=array();
$iDesc=array();
$content=array();

foreach($data1 as $key=>$value){
if($key>0 AND $key!=30){
echo "<li>";
$value=str_replace("</item>","",$value);
$iTitle[$key]=mb_substr(strip_tags(substr($value,strpos($value,"<title>"),strpos($value,"</title>"))),0,30,'UTF-8');
$content[$key]=substr($value,strpos($value,"<content:encoded>"),strpos($value,"</content:encoded>")); //<content:encoded>
$iLink[$key]=strip_tags(substr($value,strpos($value,"<link>"),strpos($value,"</link>")-strpos($value,"<link>")));
$iDesc[$key]=strip_tags(substr($value,strpos($value,"<description>"),strpos($value,"</description>")-strpos($value,"<description>")));
preg_match('/src="(.*?)"/', $content[$key], $matches);
//echo $matches[1]."<br>";
echo '<img src="'.$matches[1].'" width="300" height="250"><br>';
echo "<a href='".$iLink[$key]."' target='_blank' />".$iTitle[$key]."....</a><br/>";
//preg_match('/src="(.*?)"/', $content[$key], $matches);
//print_r($matches);

//print_r($matches);
echo "</li>\n";

}
}
?>
        </ul>
        <br style="clear: left" />
    </div>

</body>
</html>


สคริปของไทยรัฐ ดึงจาก xml ใช่มั้ยครับ
ถ้าเว็บอื่น เราก็ต้องไปหา rss จากเว็บอื่นด้วยเปล่าครับ :wanwan017:
เหนื่อย..

adjobb

อันแรกนะครับ ดึงข่าวจากไทยรัฐ....

ส่วนมากเว็บใหญ่ๆมักจะมี rss หรือ feed อยู่แล้วครับ
แต่เอาไปดัดแปลงได้ครับ ดึงส่วน html มา แล้วเอามาตัด

reviewer

คุณเชื่อไหมว่า มีพื้นฐานเกือบครบแล้วในไทยเสียว เหลือแต่ให้เราเอาไปประยุกต์ใช้งานจริง
USO (USer Optimization) สำคัญกว่า SEO?? 
SEO Reviewer  do for more Review [direct=index.php?action=profile;u=215489]Seo reviewer[/direct] are reviewed by reviewer . Just kidding. IM Employment :[direct=index.php/topic,3133.0.html]IM SALER[/direct]  and [direct=index.php/topic,273686.0.html]IM BUYER[/direct] of property should make certain that IM  professionals.
ทำไมข้อสอบม.ต้นเยอะจัง อยากไปเรียนมหาวิทยาลัย[direct=index.php/topic,319765.0.html]ก้ามหด[/direct]จัง


Juststarted