search

我想实现通过淘宝号查询淘宝买家信誉的功能,就像131458.com的一样。
我的思路是通过curl采集这个网站的数据。但是却被防了,返回给我的是无用的信息。 
代码如下:

    $parm=$data['parm']."&_=".time()."326"; //参数    $ch=  curl_init();     $uri="http://www.131458.com/handler/TaobaoInfo.ashx?";    curl_setopt($ch, CURLOPT_URL, $uri.$parm);     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);     curl_setopt($ch, CURLOPT_HEADER, 0);     curl_setopt($ch, CURLOPT_REFERER, "http://www.131458.com/");     //curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:125.67.52.246', 'CLIENT-IP:125.67.52.246'));      curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 SE 2.X MetaSr 1.0"); /     $return = curl_exec($ch);       curl_close($ch);       echo $return;

请问还要添加什么,才能模拟浏览器访问,采集到正常数据。


回复讨论(解决方案)

抓包看看呢?一般都是header里面需要啥,就都传过去

首先,你的方法不对,则是chrome F12下跟踪的结果,CURL命令如下:

curl "http://www.131458.com/handler/TaobaoInfo.ashx?tbNickInfoJson=hades&token=736905fff9ee639a4b5f46b53526434b_0b32d3aec47ad29fef2d7ddb67831933&_=1447405734036" -H "Cookie: ASP.NET_SessionId=4ki3s2yhj2555bzxlbvdqhju; Hm_lvt_ccc93bebd5e7bdc84975186073891702=1447405635; Hm_lpvt_ccc93bebd5e7bdc84975186073891702=1447405635; bdshare_firstime=1447405634805" -H "Accept-Encoding: gzip, deflate, sdch" -H "Accept-Language: zh-CN,zh;q=0.8" -H "User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.86 Safari/537.36" -H "Accept: application/json, text/javascript, */*; q=0.01" -H "Referer: http://www.131458.com/" -H "X-Requested-With: XMLHttpRequest" -H "Connection: keep-alive" --compressed

一次不好完成的curl.
截图:

<?php$tb_nick_name = '1心一易';$cookie_file = './cookies.txt';$post = array(    'nick' => escape($tb_nick_name));$url = 'http://www.131458.com/handler/load.aspx/Load';// 初始化$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($post));curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file);curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);$response = curl_exec($curl);curl_close($curl);$d = json_decode($response)->d;$_token = md5($d . 'vvl81');$url = 'http://www.131458.com/handler/TaobaoInfo.ashx?nickCode=' . escape($tb_nick_name) . '&token=' . $_token . '_' . $d . '&_=' . time() . rand(100, 999);$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);$contents = curl_exec($curl);curl_close($curl);/* * $preg = "/<script[^>]*?>.*?<\/script>/si"; * $newstr = preg_replace($preg,"",$contents); */echo htmlspecialchars($contents);function escape($string){    $n = $bn = $tn = 0;    $output = '';    $special = "-_.+@/*0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";    while ($n < strlen($string)) {        $ascii = ord($string[$n]);        if ($ascii == 9 || $ascii == 10 || (32 <= $ascii && $ascii <= 126)) {            $tn = 1;            $n ++;        } elseif (194 <= $ascii && $ascii <= 223) {            $tn = 2;            $n += 2;        } elseif (224 <= $ascii && $ascii <= 239) {            $tn = 3;            $n += 3;        } elseif (240 <= $ascii && $ascii <= 247) {            $tn = 4;            $n += 4;        } elseif (248 <= $ascii && $ascii <= 251) {            $tn = 5;            $n += 5;        } elseif ($ascii == 252 || $ascii == 253) {            $tn = 6;            $n += 6;        } else {            $n ++;        }        $singleStr = substr($string, $bn, $tn);        $charVal = bin2hex(iconv('utf-8', 'ucs-2', $singleStr));        if (base_convert($charVal, 16, 10) > 0xff) {            if (! preg_match("/win/i", PHP_OS))                $charVal = substr($charVal, 2, 2) . substr($charVal, 0, 2);            $output .= '%u' . $charVal;        } else {            if (false !== strpos($special, $singleStr))                $output .= $singleStr;            else                $output .= "%" . dechex(ord($string[$bn]));        }                $bn = $n;    }    return $output;}

一次不好完成的curl.
截图:

<?php$tb_nick_name = '1心一易';$cookie_file = './cookies.txt';$post = array(    'nick' => escape($tb_nick_name));$url = 'http://www.131458.com/handler/load.aspx/Load';// 初始化$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($post));curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file);curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);$response = curl_exec($curl);curl_close($curl);$d = json_decode($response)->d;$_token = md5($d . 'vvl81');$url = 'http://www.131458.com/handler/TaobaoInfo.ashx?nickCode=' . escape($tb_nick_name) . '&token=' . $_token . '_' . $d . '&_=' . time() . rand(100, 999);$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);$contents = curl_exec($curl);curl_close($curl);/* * $preg = "/<script[^>]*?>.*?<\/script>/si"; * $newstr = preg_replace($preg,"",$contents); */echo htmlspecialchars($contents);function escape($string){    $n = $bn = $tn = 0;    $output = '';    $special = "-_.+@/*0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";    while ($n < strlen($string)) {        $ascii = ord($string[$n]);        if ($ascii == 9 || $ascii == 10 || (32 <= $ascii && $ascii <= 126)) {            $tn = 1;            $n ++;        } elseif (194 <= $ascii && $ascii <= 223) {            $tn = 2;            $n += 2;        } elseif (224 <= $ascii && $ascii <= 239) {            $tn = 3;            $n += 3;        } elseif (240 <= $ascii && $ascii <= 247) {            $tn = 4;            $n += 4;        } elseif (248 <= $ascii && $ascii <= 251) {            $tn = 5;            $n += 5;        } elseif ($ascii == 252 || $ascii == 253) {            $tn = 6;            $n += 6;        } else {            $n ++;        }        $singleStr = substr($string, $bn, $tn);        $charVal = bin2hex(iconv('utf-8', 'ucs-2', $singleStr));        if (base_convert($charVal, 16, 10) > 0xff) {            if (! preg_match("/win/i", PHP_OS))                $charVal = substr($charVal, 2, 2) . substr($charVal, 0, 2);            $output .= '%u' . $charVal;        } else {            if (false !== strpos($special, $singleStr))                $output .= $singleStr;            else                $output .= "%" . dechex(ord($string[$bn]));        }                $bn = $n;    }    return $output;}



非常感谢你。 
我现在有一个问题,就是获取了d之后,会调用一个$.TO函数,返回的结果你是怎么分析出来,是一个md5(d."vvl81")的,我只看到了定义了C="vvl",然后他手动添加了"8",最后一个"1"是怎么知道的。
主要是网站现在已经改了,在后面加个"1"再md5已经和网站的数据不一样了。


一次不好完成的curl.
截图:

<?php$tb_nick_name = '1心一易';$cookie_file = './cookies.txt';$post = array(    'nick' => escape($tb_nick_name));$url = 'http://www.131458.com/handler/load.aspx/Load';// 初始化$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_POST, 1);curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($post));curl_setopt($curl, CURLOPT_COOKIEJAR, $cookie_file);curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);$response = curl_exec($curl);curl_close($curl);$d = json_decode($response)->d;$_token = md5($d . 'vvl81');$url = 'http://www.131458.com/handler/TaobaoInfo.ashx?nickCode=' . escape($tb_nick_name) . '&token=' . $_token . '_' . $d . '&_=' . time() . rand(100, 999);$curl = curl_init($url);$header = array();$header[] = 'Content-Type: application/json; charset=UTF-8';$header[] = 'User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.90 Safari/537.36';curl_setopt($curl, CURLOPT_HTTPHEADER, $header);curl_setopt($curl, CURLOPT_HEADER, 0);curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file);$contents = curl_exec($curl);curl_close($curl);/* * $preg = "/<script[^>]*?>.*?<\/script>/si"; * $newstr = preg_replace($preg,"",$contents); */echo htmlspecialchars($contents);function escape($string){    $n = $bn = $tn = 0;    $output = '';    $special = "-_.+@/*0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";    while ($n < strlen($string)) {        $ascii = ord($string[$n]);        if ($ascii == 9 || $ascii == 10 || (32 <= $ascii && $ascii <= 126)) {            $tn = 1;            $n ++;        } elseif (194 <= $ascii && $ascii <= 223) {            $tn = 2;            $n += 2;        } elseif (224 <= $ascii && $ascii <= 239) {            $tn = 3;            $n += 3;        } elseif (240 <= $ascii && $ascii <= 247) {            $tn = 4;            $n += 4;        } elseif (248 <= $ascii && $ascii <= 251) {            $tn = 5;            $n += 5;        } elseif ($ascii == 252 || $ascii == 253) {            $tn = 6;            $n += 6;        } else {            $n ++;        }        $singleStr = substr($string, $bn, $tn);        $charVal = bin2hex(iconv('utf-8', 'ucs-2', $singleStr));        if (base_convert($charVal, 16, 10) > 0xff) {            if (! preg_match("/win/i", PHP_OS))                $charVal = substr($charVal, 2, 2) . substr($charVal, 0, 2);            $output .= '%u' . $charVal;        } else {            if (false !== strpos($special, $singleStr))                $output .= $singleStr;            else                $output .= "%" . dechex(ord($string[$bn]));        }                $bn = $n;    }    return $output;}



非常感谢你。 
我现在有一个问题,就是获取了d之后,会调用一个$.TO函数,返回的结果你是怎么分析出来,是一个md5(d."vvl81")的,我只看到了定义了C="vvl",然后他手动添加了"8",最后一个"1"是怎么知道的。
主要是网站现在已经改了,在后面加个"1"再md5已经和网站的数据不一样了。

你可以在console里alert($.To);

return e = 2147483648 & a, f = 2147483648 & b, c = 1073741824
你看下他引用的jquery文件,在最后加了个函数。
看到这几个数字就是MD5加密了,再把格式化下,可以看出加了个1了。

要是被改了估计被发现采集了吧

你看下这网站定义的歌函数,现在变成了
_token=$.To(data.d+c+ "822")+"_"+data.d

所以还是一样的,

md5($d . 'vvl8221');

这里的值每天都在变,你不要写固定了

_token=$.To(data.d+c+ "822")+"_"+data.d

谢谢大家,已经写好了。 特别感谢u012771039,现在结贴

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
11 Best PHP URL Shortener Scripts (Free and Premium)11 Best PHP URL Shortener Scripts (Free and Premium)Mar 03, 2025 am 10:49 AM

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Introduction to the Instagram APIIntroduction to the Instagram APIMar 02, 2025 am 09:32 AM

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Working with Flash Session Data in LaravelWorking with Flash Session Data in LaravelMar 12, 2025 pm 05:08 PM

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

Build a React App With a Laravel Back End: Part 2, ReactBuild a React App With a Laravel Back End: Part 2, ReactMar 04, 2025 am 09:33 AM

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Simplified HTTP Response Mocking in Laravel TestsSimplified HTTP Response Mocking in Laravel TestsMar 12, 2025 pm 05:09 PM

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

cURL in PHP: How to Use the PHP cURL Extension in REST APIscURL in PHP: How to Use the PHP cURL Extension in REST APIsMar 14, 2025 am 11:42 AM

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

12 Best PHP Chat Scripts on CodeCanyon12 Best PHP Chat Scripts on CodeCanyonMar 13, 2025 pm 12:08 PM

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Announcement of 2025 PHP Situation SurveyAnnouncement of 2025 PHP Situation SurveyMar 03, 2025 pm 04:20 PM

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment