使用php采集电商网站的商品信息
<?php require ("phpquery/phpQuery/phpQuery.php"); $filePath1=$_POST["pname"]; if($filePath1){ $fileContent = file_get_contents($filePath1);//缓存网页 phpquery::newDocumentHTML($fileContent); //初始化,读取html源码 $match = pq(".m-detail-main-title > h1")->html(); $content_list=pq("#introPanel")->html(); $jiage=pq(".m-detail-main-one-price:first-child")->html(); }else{ $match=""; $content_list=""; $filePath1=""; $jiage=""; } ?> <!DOCTYPE HTML> <html> <head> <title>随意一个页面的商品采集系统</title> <meta http-equiv="Content-Type" content="text/html;charset=utf-8"> </head> <body> <div style="width:800px; border:1px solid #ccc; margin:15px auto; padding:10px;"> <form action="caiji.php" method="post"> <p>采集地址:<input type="text" name="pname" style="width:600px;" value="<?php echo $filePath1?>"/></p> <p>商品标题:<input type="text" name="ptitle" style="width:600px;" value="<?php echo $match;?>"/></p> <p>商品价格:<input type="text" name="ptitle" style="width:600px;" value="<?php echo $jiage;?>"/></p> <p><p>商品内容:</p><textarea style="width:600px; margin-left:70px; height:400px;"><?php echo $content_list?></textarea></p> <p><button>一键采集</button></p> </form> </div> </body> </html> <!-- <div class="thumb" id="Thumb-13164-3640" style="position: absolute; left: 0px; top: 0px;"> <a href="/Spiderman-City-Drive"> <img src="/thumb/12/Spiderman-City-Drive.jpg" alt=""> <span class="GameName" id="GameName-13164-3640" style="display: none;">Spiderman City Drive</span> <span class="GameRating" id="GameRating-13164-3640" style="display: none;"> <span style="width: 68.14816px;"></span> </span> </a> </div> <div class="thumb" id="Thumb-13169-5946" style="position: absolute; left: 190px; top: 0px;"> <a href="/Spiderman-City-Raid"> <img src="/thumb/12/Spiderman-City-Raid.jpg" alt=""> <span class="GameName" id="GameName-13169-5946" style="display: none;">Spiderman - City Raid</span> <span class="GameRating" id="GameRating-13169-5946" style="display: none;"> <span style="width: 67.01152px;"></span> </span> </a> </div> -->
这里以采集网易一元云购 为列子随便选择一个商品进行采集会显示价格 图片 名字等
http://1.163.com
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: php网页采集 修改版
- 下一篇: DedeCMS采集后如何批量修改作者和来源的方法