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

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

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

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

$100perday

เป็นปัญหาปวดตับจริง ๆ ครับ ค้นหาความรู้จากหลายสำนักแล้วครับ ไม่ลงตัวสักที ครั้งนี้เลยมาขอคตวามรู้อย่างจริงจัง ขอคนเมตตาน่ะครับ ผ่านสังเวียนโปรแกรมมิ่งมาเยอะ แต่ Auto post จนปัญหาจริง ๆ

ตัวอย่าง http://news.mthai.com/world-news/213681.html
ความต้องการ
1. ดึงหัวข้อ จัดอันดับมหาวิทยาลัยสีเขียวโลก มหิดล แชมป์ประเทศไทย ไว้ในฟิลด์ชื่อว่า topic
2. ดึง URL ของรูป มาไว้ในฟิลด์ชื่อว่า photo
3. ดึงเนื้อหา เฉพาะของข่าวนี้ ไว้ในฟิลด์ชื่อ message

ฐานข้อมูลชื่อ MyDB
ตารางชื่อ MyTB

** ต้องการที่จะดึงได้ทุกเว็บทุกหมวด
** ตั้งเวลาในการโพสต์ได้ เช่น วันละกี่โพสต์ เวลาไหนได้บ้าง ประมาณนี้อ่ะครับ

รบกวนขอแนทางทีนะครับ หรือ code ที่ผมเอาไปต่อยอดก็ได้ครับ

ขอบคุณอย่างมากครับ  :wanwan017:
เหนื่อย..


$100perday

สคริปที่จะนำมาใช้ เป็นสคริปที่เขียนเองอ่ะครับ ไม่ได้เขัยนด้วย CMS อย่างเช่น Smf , dizcus , WP อ่ะครับ
เหนื่อย..

mikeyx

เคยแต่ดึงมาทั้งหน้าครับ ทำแต่กับ amazon แล้ว บันทึกลง ฐานข้อมูล

$100perday

อ้างถึงจาก: mikeyx ใน 21 มกราคม 2013, 09:46:43
เคยแต่ดึงมาทั้งหน้าครับ ทำแต่กับ amazon แล้ว บันทึกลง ฐานข้อมูล

หมายถึงดึงทั้งหน้าเหรอครับ
และส่วนไหนบ้างครับที่เก็บลงฐานข้อมูลน่ะครับ  :wanwan020:
เหนื่อย..

mikeyx

ตัวอย่างของเว็บไทยที่ผมทำ
if(time()>=strtotime("00:00:00") && time()<strtotime("20:00:00")){ //ระยะเวลาช่วงที่คนเล่นมาก ๆ ให้เอาข้อมูลจากฐานข้อมูลมาแสดง
$query = mysql_query(.................);
$result = mysql_fetch_array($query);
echo $result[.........];
}else{ // ถ้านอกนั้น
$data=file_get_contents("........................."); //ดึงข้อมูลหน้าที่ต้องการ
แล้ว insert in to $data ลงฐานข้อมูล
และแสดง $data ด้วย
ก่อนจะแสดงก็ให้ตัดพวก html table div script ออกให้หมด เหลือแต่ text เพียว ๆ
}

zidit

ดึง html โค้ดมาเก็บในตัวแปรก่อน แล้วใช้พวก regex ครับ

ultimatecha


sbaydee

ใช้ curl ดึงมาแล้วก็ค่อยๆตัดแท็กที่ไม่ต้องการออกจนเหลือสิ่งที่ต้องการครับ

$100perday

เหนื่อย..

moshikub1

[direct=http://xn--72c6afaabg9f6ca6ci1b0pmcr0c.com]งานออนไลน์[/direct] | [direct=http://www.xn--l3cuicec1bie1f0ac4mg5cze.com]รายได้เสริม[/direct] |   [direct=http://www.xn--l3cuicec1bie1f0ac4mg5cze.com]รายได้พิเศษ[/direct] | [direct=http://xn--12cbfs2fia1ehdz2gga2etb5bxa7l1d6c8e.com/]ธุรกิจออนไลน์[/direct] | [direct=http://www.niyombrand.com]ชุดเวียดนาม[/direct]

รับปั่น UIP ละ 6 บาทต่อเดือน เช่น 1000UIP/วัน = 6000 บาท จำนวนเยอะต่อรองราคาได้ เป็นคนไทยคนจริง 99%

รับทำ Autopost CURL หน้าเว็บได้ทุกรูปแบบครับ PM มาได้เลย ราคาสบายๆ

rnon

ได้รึยังครับ
ถ้าไม่ได้เดียวส่งให้

█ [direct=https://www.youtube.com/playlist?list=PLg0-B6oZ1wT9UX4PPVQDpnZiu625e-vcf]SketchUp[/direct]
█ [direct=http://อําเภอเขาวง.blogspot.com]IINON[/direct]
█ [direct=https://www.ce.in.th]SketchUP , Layout[/direct]

navico


$100perday

อ้างถึงจาก: rnon ใน 21 มกราคม 2013, 20:30:28
ได้รึยังครับ
ถ้าไม่ได้เดียวส่งให้

ยังเลยครับPM ไปแล้วนะครับ
ขอบคุณมากครับ
เหนื่อย..

mymo


NightClub

รับจ้างเขียนโปรแกรม PHP งานมืออาชีพ เสร็จตามที่กำหนด ราคาปานกลาง
เหมาะกับผู้ที่รับงานมาแล้วส่งต่อจ๊ะ PM มาเลย

$100perday

เหนื่อย..

adjobb

เท่าที่รู้มาใช้ str replace และ Regular Expression ครับ
ในการกำหนดดึงเป็นส่วนๆ เช่นหัวข้อ เนื้อหา ภาพ

แล้วจากนั้นก็ดึงเก็บลงฐานข้อมูลครับ ของเอ็มไทยง่ายหน่อย มี feed


ถ้ายังไงสนใจโค้ด เดียว PM ไปให้ครับ โค้ดสั้นมากก

nuugib

curl เก็บ content ของเว็บเป้าหมายค่ะ

ส่วนจะให้ auto post  โดยเอาลง db ก่อน คงต้องอาศัย crontab

หรือไม่ก็ศึกษา xml rpc ยิงเข้าไปที่ wordpress ตรงๆ

$100perday

อ้างถึงจาก: adjobb ใน 22 มกราคม 2013, 00:38:15
เท่าที่รู้มาใช้ str replace และ Regular Expression ครับ
ในการกำหนดดึงเป็นส่วนๆ เช่นหัวข้อ เนื้อหา ภาพ

แล้วจากนั้นก็ดึงเก็บลงฐานข้อมูลครับ ของเอ็มไทยง่ายหน่อย มี feed


ถ้ายังไงสนใจโค้ด เดียว PM ไปให้ครับ โค้ดสั้นมากก

ขอบคุณมากครับ :wanwan017:
เหนื่อย..

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