闲鱼商品详情接口实现,主要是爬取网页端商品详情数据url地址:
https://h5api.m.taobao.com/h5/mtop.taobao.idle.awesome.detail/1.0/?jsv=2.4.5&appKey=12574478&t=1592477911574&sign=b2aa128cf2a03abf69d7708473bac731&api=mtop.taobao.idle.awesome.detail&v=1.0&AntiCreep=true&AntiFlood=true&preventFallback=true&type=jsonp&dataType=jsonp&callback=mtopjsonp2&data=%7B%22itemId%22%3A%22620691241377%22%7D
最终实现效果:
最终数据如下:
{“api”:“mtop.taobao.idle.awesome.detail”,“data”:{“needDecryptKeys”:[“sellerDO.nick”,“sellerDO.uniqueName”],“itemDO”:{“priceUnit”:"",“imageInfos”:[{“major”:“true”,“videoId”:“0”,“widthSize”:“1080”,“heightSize”:“896”,“type”:“0”,“url”:“http://img.alicdn.com/bao/uploaded/i3/O1CN01waLaoh1nb3Il5LqNl_!!0-fleamarket.jpg”,“labels”:[{“orientation”:“2”,“top”:“0.3313343328335832”,“left”:“0.6844444173177083”,“actionUrl”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”,“text”:“徽缘.伟”}]},{“major”:“false”,“videoId”:“0”,“widthSize”:“1080”,“heightSize”:“804”,“type”:“0”,“url”:“http://img.alicdn.com/bao/uploaded/i3/O1CN01dv49lC1gfuBgmpO72_!!0-fleamarket.jpg”,“labels”:[{“orientation”:“2”,“top”:“0.32733632420850123”,“left”:“0.6337777506510417”,“actionUrl”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”,“text”:“徽缘.伟”}]},{“major”:“false”,“videoId”:“0”,“widthSize”:“1080”,“heightSize”:“860”,“type”:“0”,“url”:“http://img.alicdn.com/bao/uploaded/i4/O1CN01xkk9AV1ofv7whllsa_!!0-fleamarket.jpg”,“labels”:[{“orientation”:“2”,“top”:“0.32083958020989506”,“left”:“0.6053333333333333”,“actionUrl”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”,“text”:“徽缘.伟”}]},{“major”:“false”,“videoId”:“0”,“widthSize”:“1080”,“heightSize”:“816”,“type”:“0”,“url”:“http://img.alicdn.com/bao/uploaded/i4/O1CN01hu1p3M1EIGVDQOe1U_!!0-fleamarket.jpg”,“labels”:[{“orientation”:“2”,“top”:“0.32133932270925086”,“left”:“0.6186666666666667”,“actionUrl”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”,“text”:“徽缘.伟”}]},{“major”:“false”,“videoId”:“0”,“widthSize”:“1080”,“heightSize”:“844”,“type”:“0”,“url”:“http://img.alicdn.com/bao/uploaded/i3/O1CN01Vxk5t01bKlpizYn2N_!!0-fleamarket.jpg”,“labels”:[{“orientation”:“2”,“top”:“0.31784107946026985”,“left”:“0.6622222086588542”,“actionUrl”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”,“text”:“徽缘.伟”}]},{“major”:“false”,“videoId”:“0”,“widthSize”:“1080”,“heightSize”:“820”,“type”:“0”,“url”:“http://img.alicdn.com/bao/uploaded/i1/O1CN01JIV4J61iv8ajkS51X_!!0-fleamarket.jpg”,“labels”:[{“orientation”:“2”,“top”:“0.31334332833583206”,“left”:“0.6364444173177083”,“actionUrl”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”,“text”:“徽缘.伟”}]}],“itemType”:“detailCommonBuy”,“quantity”:“1”,“simpleItem”:“true”,“originalPrice”:“0”,“transportFee”:“0.00”,“itemStatusStr”:“在线”,“favorCnt”:“4”,“templateId”:“0”,“title”:“玉化手串8.2,22.8克!”,“labels”:[{“display”:"#徽缘.伟",“url”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”},{“display”:"#徽缘.伟",“url”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”},{“display”:"#徽缘.伟",“url”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”},{“display”:"#徽缘.伟",“url”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”},{“display”:"#徽缘.伟",“url”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”},{“display”:"#徽缘.伟",“url”:“https://market.m.taobao.com/app/idleFish-F2e/app-channels/search_set?wh_weex=true&tagCode=0&tagName=%E5%BE%BD%E7%BC%98.%E4%BC%9F&reqFrom=DETAIL_ITEMTAG&bizType=customTag&condition=%7B%22itemId%22%3A%22615441296179%22%7D”}],“itemId”:“615441296179”,“trackParams”:{“itemId”:“615441296179”,“sellerId”:“1104528449”,“sellerBucketId”:“10”},“wantCnt”:“37”,“itemStatus”:“0”,“soldPrice”:“1200”,“secuGuide”:{“secuTitle”:“什么是闲鱼支付宝担保交易?”,“secuIcon”:“https://gw.alicdn.com/tps/TB1xwS9MVXXXXbGXVXXXXXXXXXX-24-24.png”,“secuContent”:“担保交易”,“secuBtmContext”:“点击查看更多知识”,“secuBtm”:“闲置商品不支持7天无理由退货服务。请保证在闲鱼平台进行支付,否则闲鱼将无法保证您交易的安全。",“secuBtmUrl”:“https://h5.m.taobao.com/alicare/index.html?from=mmcHJdQwpZ”,“secuBody”:“https://gw.alicdn.com/mt/TB1V4Q9OVXXXXa7aXXXXXXXXXXX-488-430.png”},“categoryId”:“50023914”,“browseCnt”:“2954”,“desc”:“玉化手串8.2,22.8克!\n感兴趣的话点“我想要”和我私聊吧~”},“sellerDO”:{“city”:“保定”,“portraitUrl”:“http://img.alicdn.com/bao/uploaded/i3/O1CN01ULbAqk1ylY68jPlrO_!!0-fleamarket.jpg”,“zhimaAuth”:“true”,“publishCity”:“发布于保定”,“nick”:"z**b”,“zhimaLevelInfo”:{“levelCode”:“A”,“levelName”:“信用极好”},“sellerId”:“1104528449”,“uniqueName”:“徽***伟”,“xianyuSummary”:“来闲鱼410天了,卖出过5件宝贝。90后巨蟹座女生。喜欢运动、音乐、娱乐。”,“cityUrl”:“https://fleamarket.taobao.com/wow/z/act/default/localCity?wh_biz=tm&wh_weex=true”,“lastVisitTime”:“刚刚擦亮”,“identityTags”:[{“iconHeight”:“32”,“trackParams”:{“appearTrackName”:"",“trackCtrlName”:“Button-Shiren”},“iconWidth”:“32”,“link”:“https://h5.m.taobao.com/2shou/pd/realVerifyUrl.html?userId=1104528449&isVerify=1”,“iconUrl”:“https://gw.alicdn.com/bao/uploaded/TB1E3aKPFXXXXcKXpXXXXXXXXXX-32-32.png”,“text”:“实人认证已通过”,“type”:“1”},{“iconHeight”:“32”,“trackParams”:{“appearTrackName”:"",“trackCtrlName”:“Button-Zhima”},“iconWidth”:“32”,“link”:“fleamarket://personalPage?userid=1104528449&ignore=false&userzhima=true&loginuserzhima=false”,“iconUrl”:“https://gw.alicdn.com/tfs/TB1DuVuB7P2gK0jSZPxXXacQpXa-32-32.png”,“text”:“芝麻信用已授权”,“type”:“100”}],“levelTags”:[{“iconHeight”:“28.0”,“iconWidth”:“129.0”,“iconUrl”:“https://gw.alicdn.com/tfs/TB1alBPybj1gK0jSZFOXXc7GpXa-168-36.png”},{“iconHeight”:“28.0”,“iconWidth”:“28.0”,“iconUrl”:“https://gw.alicdn.com/tfs/TB1DM04aGWs3KVjSZFxXXaWUXXa-28-28.png”}]},“trackParams”:{“itemId”:“615441296179”,“sellerOptions”:“simplePub|newTagPage|myPubSameSpu|toBuyB|spuGuide|itemGuide|myTabAlert|tagV2|glbV2|textSameSpu|mtbFeeds|mtbSell|mtbHome”,“sellerId”:“1104528449”,“detailRedirectPublishUrl”:“https://market.m.taobao.com/app/idleFish-F2e/purchaseMatch/pages/new-custom-demand?wh_weex=true&needLogin=1&need_login=true&scene=toBuyPubDetailPush&sourceId=bid_detail_button&spuId=-1&itemId=615441296179&tbNid=0&transparent=true&hideNavBar=true&is_modal=true&modalPStyle=true”,“mainPic”:“http://img.alicdn.com/bao/uploaded/i3/O1CN01waLaoh1nb3Il5LqNl_!!0-fleamarket.jpg”,“sellerBucketId”:“10”,“sellerInBuyBucketId”:“11”,“sellerInBuyOptions”:“newTagPage|pop”,“categoryId”:“50023914”},“serverTime”:“2020-06-18 21:46:14”},“ret”:[“SUCCESS::调用成功”],“v”:“1.0”}
语言实现:
php + nodejs
nodejs实现sign算法(核心)
php实现爬虫 (可以改写为任何的语言形式)
目前 基本上实现了毫秒级别能爬1条数据
需要的请联系我 QQ: 84075041, 此技术仅供参考!
代码截图:
handler = new Redis(); //从配置读取 $this->handler->connect($data['hostname'], $data['port']); $this->handler->auth($data['auth']); $this->handler->select($dbindex); } public static function getInstance($dbindex = 0) { if (!isset(self::$_instance[$dbindex]) or FALSE == (self::$_instance[$dbindex] instanceof self)) { self::$_instance[$dbindex] = new self($dbindex); } return self::$_instance[$dbindex]; } /**key value get**/ public function GET($key) { return $this->handler->get($key); } /**key value set 过期时间为 $exp**/ public function SET($key, $value, $exp) { $this->handler->setex($key, $exp, $value); } public function __destruct() { if ($this->handler) { $this->handler->close(); } } } /** * Created by PhpStorm. * User: Administrator * Date: 2017/9/28 0028 * Time: 18:20 */ class Network { public static function RequestData($url, $data = null) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)) { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data)); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl); return $output; } } function getItemInfo($itemid){ global $config ; $tkCookie = getTkCookie(); $commend = $config['node_bin'] . " " .$config['project_path'] . "/cookie.js {$itemid} {$tkCookie['_m_h5_tk']} {$tkCookie['_m_h5_tk_all']} {$tkCookie['_m_h5_tk_enc']}"; $url = trim(my_exec($commend)); //echo "url is : " . $url . "\n"; //echo "Cookie:_m_h5_tk={$tkCookie['_m_h5_tk_all']};_m_h5_tk_enc={$tkCookie['_m_h5_tk_enc']} ". "\n"; $ipData = getProxyIp(); if( empty($ipData['ip']) ){ echo date("Y-m-d H:i:s" , time()) . ">>>>>>没有获取到代理的IP \n"; return []; } //print_r($ipData); $headers = array( "User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:77.0) Gecko/20100101 Firefox/77.0", "Cookie:_m_h5_tk={$tkCookie['_m_h5_tk_all']};_m_h5_tk_enc={$tkCookie['_m_h5_tk_enc']}", "Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "Cache-Control:max-age=0", "Referer:https://market.m.taobao.com/app/idleFish-F2e/widle-taobao-rax/page-detail?wh_weex=true&wx_navbar_transparent=true&id=620691241377&ut_sk=1.Xorif98ZyO4DAFOaBXKdI6l2_21407387_1592450094432.Copy.detail.620691241377.1094213846&forceFlush=1", ); //print_r($headers); $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => $url , CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 100, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "GET", CURLOPT_HTTPHEADER => $headers, CURLOPT_SSL_VERIFYHOST => false , CURLOPT_SSL_VERIFYPEER => false , //CURLOPT_PROXY => $ipData['ip'], CURLOPT_PROXYPORT => $ipData['port'], CURLOPT_USERPWD => "{$config['proxy']['AuthKey']}:{$config['proxy']['AuthPwd']}", CURLOPT_PROXYTYPE => CURLPROXY_HTTP, CURLOPT_HTTPAUTH => CURLAUTH_BASIC )); $resp_str = curl_exec($curl); $err = curl_error($curl); curl_close($curl); //echo "resp:" . $resp_str; $result = json_decode( $resp_str , true ); $title = isset( $result['data']['itemDO']['title']) ?$result['data']['itemDO']['title'] :"" ; $itemStatus = isset( $result['data']['itemDO']['itemStatus']) ?$result['data']['itemDO']['itemStatus'] :"" ; $itemStatusStr = isset( $result['data']['itemDO']['itemStatusStr']) ?$result['data']['itemDO']['itemStatusStr'] :"" ; $soldPrice = isset( $result['data']['itemDO']['soldPrice']) ?$result['data']['itemDO']['soldPrice'] :"" ; $nick = isset( $result['data']['sellerDO']['nick']) ?$result['data']['sellerDO']['nick'] :"" ; if( empty($title) ){ //delProxyIpCache(); } //print_r($result); //成功率统计下 if( empty($title) ){ $handler = RedisDB::getInstance(12)->handler; $handler->incr("s_".date("YmdH")); //$handler->incr("s_".date("YmdHi")); } $res = [ 'title' => $title , 'itemStatus' => $itemStatus, 'itemStatusStr' => $itemStatusStr, 'nick' => $nick, 'resp' => $resp_str, 'soldPrice' => $soldPrice ] ; if( empty($title ) ){ echo date("Y-m-d H:i:s" , time()) . ">>>>没有爬到数据返回:" .$resp_str . "\n" ; }else{ echo date("Y-m-d H:i:s" , time()) . " >>>>标题:" .$title. " , 价格:{$soldPrice} , 状态:{$itemStatusStr} \n" ; echo "接口文档地址:
https://www.showdoc.cc/985778661176731?page_id=5110060088025794
在线解码地址 : 在线base64解码
# 下面是进行base64编码的 解码就可以看到我了!!
# cXE6IDg0MDc1MDQx