perlhttphttp-headerswww-mechanize

Most generic mobile User-Agent header string


I use LWP::UserAgent to access the web site. The site offers almost the same info in auto-selected layouts for pc (default?) and mobile. Some informations are easier to get in non default layout.

Which User-Agent most generic strings are recommended to identify web client as mobile or pc device?
LWP::UserAgent : $ua->agent('…');

P.S. So far for tests I use full string of randomly selected mobile device. It works but I would like to set proper "style-guide" - set and forget for LONG. I would like to avoid requirement for fixes every few years.


Solution

  • In my specific case Mozilla/5.0 (Mobile) delivers wanted results.
    IMHO it is worth to try in other cases.

    $ua->agent('Mozilla/5.0 (Mobile)');
    

    I have tried it based on suggestion in
    https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent

    Firefox UA string

    […] The UA string of Firefox itself is broken down into four components:

    Mozilla/5.0 (platform; rv:geckoversion) Gecko/geckotrail Firefox/firefoxversion

    • Mozilla/5.0 is the general token that says the browser is Mozilla compatible, and is common to almost every browser today.
    • platform describes the native platform the browser is running on (e.g. Windows, Mac, Linux or Android), and whether or not it's a mobile phone. Firefox OS phones simply say "Mobile"; the web is the platform.
      […]