简体   繁体   English

PHP Curl从浏览器中的URL返回不同的结果

[英]PHP Curl return different results from URL in browser

I am using PHP Curl with this code: 我在此代码中使用PHP Curl:

curl_setopt($ch, CURLOPT_URL, 'https://www.segundamano.mx/anuncios/ciudad-de-mexico/alvaro-obregon/florida/renta-inmuebles/departamentos?precio=0-10000');
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookies);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookies);

curl_setopt($ch, CURLOPT_HEADER, false); 
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);  
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 

//curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0");

$uagent = 'Mozilla/5.0 (Windows NT 6.1; rv:22.0) Firefox/22.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/36.0.1985.125 Chrome/36.0.1985.125 Safari/537.36';
curl_setopt($ch, CURLOPT_USERAGENT, $uagent);

curl_setopt($ch, CURLOPT_REFERER, 'http://www.google.com');
curl_setopt($ch, CURLOPT_AUTOREFERER, true); 

My question is.. why PHP Curl gives different result Than Searching URL in BROWSER? 我的问题是..为什么PHP Curl与在BROWSER中搜索URL相比会得到不同的结果?

PHP Curls gives a big BODY CONTENT... with this LINE... In Spanish... "No encontramos resultados para tu búsqueda..." In English.....There are no results for your search... PHP Curls使用此行提供了很大的内容...西班牙语...“没有encontramos resultados para tubúsqueda...”英语.....没有搜索结果...

What happen with this URL? 这个网址会怎样? How Can I CURL and read by code this URL and get the REAL RESULTS AS BROWSER? 我如何卷曲并通过代码读取该URL并获得浏览器的真实结果?

Help me please! 请帮帮我! Thanks!!! 谢谢!!!

The link you have mentioned is a single-page web application or web site that interacts with the user by dynamically rewriting the current page rather than loading entire new pages from a server. 您提到的链接是单页Web应用程序或网站,它通过动态重写当前页面而不是从服务器加载整个新页面来与用户交互。

Also, this website is using vue js. 另外,该网站正在使用vue js。

Please find the below links for more details. 请找到以下链接以获取更多详细信息。

https://en.wikipedia.org/wiki/Single-page_application https://vuejs.org/ https://zh.wikipedia.org/wiki/单页应用 https://vuejs.org/

Because JavaScript is the root of all evil. 因为JavaScript是万恶之源。 the website gets the search results you want with AJAX after you've succesfully loaded the page. 成功加载页面后,网站将使用AJAX获得所需的搜索结果。 Just open the "network" tab of your browser inspection tool and see the requests flying around. 只需打开浏览器检查工具的“网络”标签,然后查看请求四处可见。

Fun part: the website does have a (seemingly authorized) API that it can talk too, maybe you can try that? 有趣的部分:该网站确实有一个(貌似已授权的)API,它也可以通话,也许您可​​以尝试? https://webapi.segundamano.mx/nga/api/v1.1/public https://webapi.segundamano.mx/nga/api/v1.1/public

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM