SEoSean
V2EX  ›  PHP

求大佬解决一下一个问题

  •  
  •   SEoSean · Nov 27, 2024 · 3511 views
  •   You need to sign in to view this topic
    This topic created in 641 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   ·   Privacy   ·   Solana   ·   842 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 21:44 · PVG 05:44 · LAX 14:44 · JFK 17:44
    ♥ Do have faith in what you're doing.