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

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

ThaiSEOBoard.comพัฒนาเว็บไซต์Programmingขอแนวทางเกี่ยวกับ Auto post หน่อยครับ ยินดีของแถมสมนาคุณเต็มที่
หน้า: 1 [2]  ทั้งหมด   ลงล่าง
พิมพ์
ผู้เขียน หัวข้อ: ขอแนวทางเกี่ยวกับ Auto post หน่อยครับ ยินดีของแถมสมนาคุณเต็มที่  (อ่าน 5317 ครั้ง)
0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้
adjobb
หัวหน้าแก๊งเสียว
*

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

กระทู้: 2,877



ดูรายละเอียด
« ตอบ #20 เมื่อ: 22 มกราคม 2013, 01:14:43 »

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

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

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

config.php
โค๊ด:
<?php
/************************/
/* หมวดของการติดต่อฐานข้อมูล */
/**********************/
$host "mysql.main-hosting.com"//ใส่ชื้อโฮสของคุณเช่น  $host = &#39;localhost&#39;;
$root "u706496516_jeDaH"//ใส่ชื่อผู้ใช้เพื่อติดต่อฐานข้อมูลเช่น  $root = &#39;root&#39;;
$pass "XubySejasu"//ใส่รหัสผ่านเพื่อติดต่อฐานข้อมูลเช่น $pass = &#39;password&#39;;
$dtbn "u706496516_RyReN"//ใส่ชื่อฐานข้อมูล  WP ของคุณเช่น $dtbn = &#39;databasename&#39;;
$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(&#39;url&#39;));

$i=0;
$strSQL "SELECT * FROM ".$fix."posts WHERE post_content_filtered = &#39;$link&#39;";
$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,&#39;<div id="details" class="page">&#39;,$next_start); 

if($next_start==0){

$end strpos($contentdata,&#39;</p></p>&#39;,$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 &#39;<a href="&#39;.$link.&#39;">&#39;.$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("&#39;"$title);
$title implode("\&#39;",$pos1);
$pos2 explode("&#39;"$content);
$content implode("\&#39;",$pos2);
$copy "<br> เนื้อหาจาก<a href=\"$link\" target =\"_blank\">หนังสือพิมพ์ไทยรัฐ</a>";
$content ="$content $copy";

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

$strSQL "SELECT * FROM ".$fix."posts WHERE post_content_filtered = &#39;$link&#39;";
$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 (&#39;
$PostID&#39;, &#39;$wp_categoriesID&#39;, &#39;0&#39;)";
$objQuery33 mysql_query($strSQL33) or die ("Error Query [".$strSQL33."]");

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



}

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

?>
« แก้ไขครั้งสุดท้าย: 22 มกราคม 2013, 01:15:45 โดย adjobb » บันทึกการเข้า
adjobb
หัวหน้าแก๊งเสียว
*

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

กระทู้: 2,877



ดูรายละเอียด
« ตอบ #21 เมื่อ: 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>
บันทึกการเข้า
$100perday
หัวหน้าแก๊งเสียว
*

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

กระทู้: 2,032



ดูรายละเอียด
« ตอบ #22 เมื่อ: 22 มกราคม 2013, 01:24:49 »

ที่บอกว่า 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
หัวหน้าแก๊งเสียว
*

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

กระทู้: 2,877



ดูรายละเอียด
« ตอบ #23 เมื่อ: 22 มกราคม 2013, 04:36:47 »

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

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

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

กระทู้: 959



ดูรายละเอียด เว็บไซต์
« ตอบ #24 เมื่อ: 22 มกราคม 2013, 05:00:35 »

เก็บก่อน ว่างเดี๋ยวมาดู
บันทึกการเข้า

คุณเชื่อไหมว่า มีพื้นฐานเกือบครบแล้วในไทยเสียว เหลือแต่ให้เราเอาไปประยุกต์ใช้งานจริง
USO (USer Optimization) สำคัญกว่า SEO?? 
SEO Reviewer  do for more Review Seo reviewer are reviewed by reviewer . Just kidding. IM Employment :IM SALER   and IM BUYER of property should make certain that IM  professionals.
ทำไมข้อสอบม.ต้นเยอะจัง อยากไปเรียนมหาวิทยาลัยก้ามหด จัง
ICheer_No0M
Newbie
*

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

กระทู้: 78



ดูรายละเอียด เว็บไซต์
« ตอบ #25 เมื่อ: 22 มกราคม 2013, 11:16:03 »

regexp คือคำตอบ  wanwan003
บันทึกการเข้า

Juststarted
ก๊วนเสียว
*

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

กระทู้: 402



ดูรายละเอียด
« ตอบ #26 เมื่อ: 23 มกราคม 2013, 15:55:13 »

เยี่ยมครับ  ความรู้ล้วนๆ  wanwan017
บันทึกการเข้า
หน้า: 1 [2]  ทั้งหมด   ขึ้นบน
พิมพ์