第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

重定向后從URL獲取內(nèi)容

重定向后從URL獲取內(nèi)容

PHP
有只小跳蛙 2021-05-12 17:58:44
我正在嘗試建立一種無需使用Twitter的API即可獲取某人的Twitter ID的工具。在我的示例中,我的用戶名是quixthe2nd。因此,如果您在此鏈接中輸入某人的Twitter用戶名:https://twitter.com/quixthe2nd/profile_image?size=original它將重定向到:https://pbs.twimg.com/profile_images/1116692743361687553/0P-dk3sF.jpgID為1116692743361687553。在后面列出https://pbs.twimg.com/profile_images/。我的代碼是:$url = "https://twitter.com/quixthe2nd/profile_image?size=original";function get_redirect_target($url){    $ch = curl_init($url);    curl_setopt($ch, CURLOPT_HEADER, 1);    curl_setopt($ch, CURLOPT_NOBODY, 1);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);    $headers = curl_exec($ch);    curl_close($ch);    // Check if there's a Location: header (redirect)    if (preg_match('/^Location: (.+)$/im', $headers, $matches))        return trim($matches[1]);    // If not, there was no redirect so return the original URL    // (Alternatively change this to return false)    return $url;}function get_redirect_final_target($url){    $ch = curl_init($url);    curl_setopt($ch, CURLOPT_NOBODY, 1);    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // follow redirects    curl_setopt($ch, CURLOPT_AUTOREFERER, 1); // set referer on redirect    curl_exec($ch);    $target = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);    curl_close($ch);    if ($target)        return $target;    return false;}    $s = $target;    if(preg_match('/profile_images\/\K[^\/]+/',$s,$matches)) {        print($matches[0]);    }我的代碼什么都不輸出。我將如何通過PHP來抓取呢?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 200 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號