如何获取cURL提取的最后一个网址? [英] How to get the last URL fetched by cURL?

查看:119
本文介绍了如何获取cURL提取的最后一个网址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果给定的网址重定向到另一个网址, cURL 将通过

If a given URL is redirected to another one, cURL will fetch the last one by

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

但是如何记录cURL提取的最后一个URL是什么?

but how to record what was the last URL fetched by cURL?

使用

curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

我们不知道 cURL ,因为 $ link 已重定向到最终位置。如何记录字符串中的最后一个位置?

we do not know what was the actuall url fetched by cURL, as $link has been redirected to the final location. How to record the last location in a string?

推荐答案

可以使用 curl_getinfo c $ c>。

You can use curl_getinfo().

http://php.net/manual/en/function.curl-getinfo.php

echo curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);

这篇关于如何获取cURL提取的最后一个网址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆