ไม่มีไรทำ ลองแจกโค้ด php ดึงสินค้าจากหน้าค้นหาอเมซอน

เริ่มโดย nistelbooy, 27 ตุลาคม 2012, 20:50:39

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

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

nistelbooy

php โค้ด *อ้างอิงจากโครงสร้างหน้าเว็บอเมซอน ในปัจจุบัน 27.10.55

อันนี้จะถึงข้อมุลสินค้าในหน้าค้นหา แสดงหน้าแรกน่ะครับ หน้าถัดไปลองเอา url มาใส่ดูครับ

การทำงานของโปรแกรม ไม่มีไรมากครับ ดึง html จาก url ด้วย file_get_contents
จากนั้นเอามาแบ่งแยกส่วนข้อมูลด้วย explode แล้วเราก็เอาข้อมุลมาเรียงตามใจชอบ
โค้ดนี้เป้นโค้ดพื้นฐานง่ายๆครับ สามารถนำไปพัฒนาต่อไป โดยอาจะทำลิ้งไปยังหน้า detail อีกทีนึง ใช้ api ดึง ค่อยยิงไปหน้าอเมซอนอีกที
ทำให้เราประหยัด api และอาจจะทำ cache ไว้ ทำให้แสดงหน้าเว็บได้เร็วยิ่งขึ้น

<?php

$tagid 
"test-20";

$kw "hdtv led 1080p";

$url "http://www.amazon.com/s/ref=nb_sb_ss_i_2_4?url=search-alias%3Daps&field-keywords=".urlencode($kw)."";

$content file_get_contents($url);

$exp1 explode('<div id="atfResults" class="list results">',$content);
$data1 $exp1[1];

$exp2 explode('<br clear="all">',$data1);

$count count($exp2);
$total $count-1;

echo 
'<table border="1" width="100%">';
for(
$i=0;$i<$total;$i++){
$_title explode('<h3 class="newaps">',$exp2[$i]);
$_title explode('</h3>',$_title[1]);

$_link explode('href="',$_title[0]);
$_link explode('">',$_link[1]);
$link trim(strip_tags($_link[0]));

$_title strip_tags($_title[0]);
$_title explode('by',$_title);
$title trim(strip_tags($_title[0]));
$by trim(strip_tags($_title[1]));

$_asin explode('dp/',$_link[0]);
$_asin explode('/ref',$_asin[1]);
$asin trim(strip_tags($_asin[0]));
$thelink "http:///www.amazon.com/gp/offer-listing/".$asin."/?tag=".$tagid;

$_image explode('src="',$exp2[$i]);
$_image explode('.jpg',$_image[1]);
$image trim(strip_tags($_image[0]));

$_order explode('sml">',$exp2[$i]);
$_order explode('</span>',$_order[1]);
$order trim(strip_tags($_order[0]));

$_price explode('<del class="grey">',$exp2[$i]);
$_price explode('</del>',$_price[1]);
$price trim(strip_tags($_price[0]));

$_price2 explode('<span class="bld lrg red">',$exp2[$i]);
$_price2 explode('</span>',$_price2[1]);
$price2 trim(strip_tags($_price2[0]));

$_bld explode('<span class="price bld">',$exp2[$i]);
$_bld explode('</span>',$_bld[1]);
$bld trim(strip_tags($_bld[0]));

$_offers explode('<span class="grey">',$exp2[$i]);
$_offers explode('</span>',$_offers[1]);
$offers trim(strip_tags($_offers[0]));

$_stars explode('class="asinReviewsSummary">',$exp2[$i]);
$_stars explode('</div>',$_stars[1]);
$_stars explode('<a alt="',$_stars[0]);
$_stars explode('out of 5 stars',$_stars[1]);
$stars trim(strip_tags($_stars[0]));

$_counts explode('<span class="rvwCnt">(',$exp2[$i]);
$_counts explode(')</span>',$_counts[1]);
$counts trim(strip_tags($_counts[0]));

echo '<tr>';
echo '<td valign="top" alig="center" width="120">';
echo '<img src="'.$image.'.jpg" border="0"> ';
echo '</td>';
echo '<td valign="top">';
echo 'Title : <a href="'.$thelink.'" target="_blank">'.$title.'</a><br />';
echo 'ASIN : '.$asin.'<br />';
echo 'Price : <strike>'.$price.'</strike> <b>'.$price2.'</b><br />';
echo 'Rating : '.$stars.' ('.$counts.')<br />';
if($order){
echo ''.$order.'<br />';
}
if($bld){
echo ''.$bld.' '.$offers.'<br />';
}
echo '</td>';
echo '</tr>';
}
echo 
'</table>';

?>


ผลลัพธ์



ถ้าคิดว่ามีประโยชน์กด + ถ้าไม่กด x

ขอบคุณครับ
งดรับงาน

Lining

[direct=http://heal.in.th/%E0%B8%A5%E0%B8%B4%E0%B9%89%E0%B8%87%E0%B8%84%E0%B9%8C%E0%B9%80%E0%B8%9E%E0%B8%B7%E0%B9%88%E0%B8%AD%E0%B8%99%E0%B8%9A%E0%B9%89%E0%B8%B2%E0%B8%99/]เว็บไม่มีอันดับ? คนเข้าเว็บน้อย? ขายสินค้าไม่ได้? !!!คลิ๊กที่นี่เพื่ออ่าน ฟรี!! วิธีทำอันดับใน Google [/direct]
[direct=http://heal.in.th]สิวอุดตัน[/direct] [direct=http://heal.in.th]วิธีรักษาสิว[/direct] [direct=http://heal.in.th]สิวผด[/direct] [direct=http://heal.in.th]รักษาสิวอุดตัน[/direct]

torvip

[direct=https://www.facebook.com/thanakasale]ทานาคา[/direct]
[direct=https://www.facebook.com/dsalecosshop]แป้งทานาคา[/direct]
[direct=https://www.thaitrips.net]จองโรงแรม[/direct]
LeadsMarket CPA Payday Loans&Legal Leads มีคนไทยให้คำแนะนำอนุมัติเร็ว[direct=http://goo.gl/CExXq] >>-<<[/direct]

zest_th


ayeweb


[direct=https://www.bitimer.in.th/]ข่าวไอที[/direct] ข่าวสารไอที แอพไอโฟน บริการอื่นๆ
[direct=https://page.line.me/gnm7628z]บริการ ตรวจหวย[/direct] อื่นๆ ทั่วไปสาระน่ารู้ ความรู้ต่างๆ
[direct=https://goo.gl/XQp91t]Host ไทย[/direct] เว็บผู้หญิงนะคะ แต่ผู้ชายก็เข้าได้ค่ะ
[direct=https://page.line.me/oer1981h]ตรวจหวย[/direct]
ตรวจหวย ผลสลากกินแบ่งรัฐบาล>>
[direct=https://goo.gl/H3JCzK]เช่าโฮสติ้ง Ruk-com[/direct]

throranin

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

[direct=http://dkikwmp.blogspot.com]ทำเนียบดารานักร้องไทย[/direct][direct=http://thai-games.com]เกมส์สนุก ต้องลอง!!![/direct][direct=https://aoomseven2018.blogspot.com/]ชมรม เศรษฐี ไม่มีเปย์[/direct] [direct=http://mysteryoverfateheaven.blogspot.com]Mystery over fate heaven[/direct][direct=http://nindiary.blogspot.com]ไดอารี่ ของ คนช่างสงสัย[/direct]

Best4u

[direct=http://ของดีราคาถูก.com]ของดีราคาถูก.com[/direct] | [direct=http://ของดีราคาถูก.blogspot.com/]ของดีราคาถูก[/direct] | [direct=http://ของดีราคาถูก.blogspot.com/2016/03/samsung-j7.html]Samsung J7 ราคาถูก ไม่พอใจยินดีคืนเงิน‎[/direct] | [direct=http://moneymachinemaker.com] Money Machine Maker ระบบเครื่องจักรทำเงิน[/direct]
[direct=http://earnmoneyonlinepageqq.blogspot.com/2017/06/promote-ads-pageqq.html][/direct]

zonecom


tagecho


system-4x

[direct=http://www.system-4x.com/board]Naruto One Piece Bleach ใหม่ล่าสุด[/direct][direct=http://www.sakidkao.com]สะกิดข่าว[/direct][direct=http://www.system-4x.com/board/index.php/board,47.0.html]ลงประกาศฟรี[/direct]

littleaff

[direct=http://aapro.bugs3.com]AAPro[/direct]

zildjiean

[direct=http://www.daylytopreview.com][/direct]

บักเชนนนน


kankab13

 :wanwan011:มีประโยชน์มากครับ สุดยอด ไม่เปลือง api amazon ด้วย ทำ เวบ คุณภาพได้ดีเลยได้ไอเดีย ใหม่ใด้ thanks
[direct=http://oveshop.us]oveshop[/direct][direct=http://oska.site]oska[/direct][direct=http://easyouttool.tk//]tk[/direct][direct=http://berngudon.com/]เบิ่งอุดร[/direct][direct=http://hakpenguin.com/]hk[/direct]

JummY HoT


VIPHealthBeauty

[direct=http://viphealthcares.com] viphealthcares.com : Health Care for VIP[/direct]



DDD1985


tiamkeaw

ถอนหายใจ