当前位置:网站首页>Learn to use PHP to get the URL address link after resetting
Learn to use PHP to get the URL address link after resetting
2022-07-25 04:45:00 【Lingering memory of Yu Fei】
Learn to use php Get after redirection url Address Links
Redirect url Packaging function
function get_location($url, $ua = 0)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$httpheader[] = "Accept:*/*";
$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
$httpheader[] = "Connection:close";
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
curl_setopt($ch, CURLOPT_HEADER, true);
if ($ua) {
curl_setopt($ch, CURLOPT_USERAGENT, $ua);
} else {
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Linux; U; Android 4.0.4; es-mx; HTC_One_X Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0");
}
curl_setopt($ch, CURLOPT_NOBODY, 1);
curl_setopt($ch, CURLOPT_ENCODING, "gzip");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$ret = curl_exec($ch);
curl_close($ch);
preg_match("/Location: (.*?)\r\n/iU", $ret, $location);
return $location[1];
}
Calling method
// Customize agent
$ua = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/604.3.5 (KHTML, like Gecko) Version/13.0 MQQBrowser/9.0.0 Mobile/15B87 Safari/604.1 MttCustomUA/2 QBWebViewType/1 WKType/1';
echo get_location('https://www.qipa250.com/aweme/v1/playwm/?video_id=v0300fg10000cb7t043c77u4jka9out0&ratio=720p&line=0', $ua);
边栏推荐
- Etcd learning
- MCU experiment record
- GDT,LDT,GDTR,LDTR
- The market is right
- 深入掌握Service
- Understand Huawei's 2018 financial report with one picture
- How to ensure data consistency between MySQL and redis?
- # 1. Excel的IF函数
- Millet 100W fast charging, 50W wireless charging technology exposure! Oppo Shen Yiren responded: boring!
- 运筹学基础【一】 之 导论
猜你喜欢

Construction of Seata multilingual system

【浅析STM32之GPIO寄存器(CRL/CRH)配置 】

实战|记一次攻防演练打点

Salt and ice particles cannot be distinguished

【基于stm32f103的SHT30温湿度显示】

Network engineering case: integrated network design of CII company

If you don't know these 20 classic redis interview questions, don't go to the interview!

01 create project warehouse
![[sht30 temperature and humidity display based on STM32F103]](/img/43/bbc66ab2d56cfa9dc05d795e8fe456.jpg)
[sht30 temperature and humidity display based on STM32F103]

Custom dialog (including header and footer)
随机推荐
Today is important
How to transfer NFT metadata from IPFs to smart contracts
盐粒和冰粒分不清
市场的调节
It we media shows off its wealth in a high profile, and is targeted by hacker organizations. It is bound to be imprisoned
If you don't know these 20 classic redis interview questions, don't go to the interview!
PHP Baidu qianqianhua installment API
How can test / development programmers with 5 years of experience break through the technical bottleneck? Common problems in big factories
Introduction to computing system hardware (common servers)
GDT,LDT,GDTR,LDTR
The market is right
Sudden! Britain accuses Huawei of major defects in its equipment (with report)
GBase JDBC 连接数据库异常
Completed project series Tutorials - smart campus management system
Docker install MySQL 5.7
【微信小程序】拍卖商品详情页设计与交互实现(包含倒计时、实时更新出价)
What is behind the development of science and technology now is the advent of the era of the meta universe
In the process of data migration from Oracle to polardb for PostgreSQL, what does data migration mean?
Pyg builds GCN to realize link prediction
1. If function of Excel