V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
SEoSean
V2EX  ›  PHP

求大佬解决一下一个问题

  •  
  •   SEoSean · Nov 27, 2024 · 3256 views
    This topic created in 518 days ago, the information mentioned may be changed or developed.

    我需要 利用 php 来获取访问的蜘蛛 需要在其他页面调用 代码应该怎么写? 求大佬给一个参考 谢谢

    5 replies    2024-11-27 22:34:19 +08:00
    Jinnrry
        1
    Jinnrry  
       Nov 27, 2024   ❤️ 1
    每个字都认识,连一起却看不懂你在说什么
    hbcolorful
        2
    hbcolorful  
       Nov 27, 2024
    @Jinnrry 我也是。。。
    GG668v26Fd55CP5W
        3
    GG668v26Fd55CP5W  
       Nov 27, 2024 via iPhone
    ChatGPT 看了直接宕机
    summerwar
        4
    summerwar  
       Nov 27, 2024
    获取 userAgent ,正规的蜘蛛都是有自己的名字的
    a570295535
        5
    a570295535  
       Nov 27, 2024 via Android
    简单写一下就行吧,蜘蛛名字随便写的不知道对不对:

    $userAgent = $_SERVER['HTTP_USER_AGENT'];

    $spiders = [
    'Baiduspider', 'Sogou', 'Googlebot', 'Bingbot', 'YandexBot'
    ];

    foreach ($spiders as $spider) {
    if (stripos($userAgent, $spider) !== false) {
    echo "访问者是:$spider";
    break;
    }
    }
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1218 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 23:26 · PVG 07:26 · LAX 16:26 · JFK 19:26
    ♥ Do have faith in what you're doing.