LINE 貼圖網址傳回的資料分析

測試,使用 curl header:

curl http://line.me/R/shop/detail/8072

傳回結果:

<html>
<head><title>302 Found</title></head>
<body bgcolor="white">
<center><h1>302 Found</h1></center>
<hr><center>nginx</center>
</body>
</html>


 

測試 iOS 平台 Header

curl -v -H 'User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10' http://line.me/R/shop/detail/8072

執行結果:

<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<title>LINE</title>
<link rel="stylesheet" href="//scdn.line-apps.com/n/line_urlscheme/css/line_urlscheme_1464238694.css">
<script src="//scdn.line-apps.com/n/line_urlscheme/js/lc.line.scheme_1464238694.js"></script>
</head>

<body>
<!--CONTENTS-AREA-->
<div class="LyContents" role="main">
<section class="MdCMN01Cont">
<p class="mdCMN01Desc">
Open the LINE app to continue.

</p>
<div class="mdCMN01Img"><img src="//scdn.line-apps.com/n/line_urlscheme/img/img_line_160830.png" alt="LINE" width="75" height="75"></div>
<div class="mdCMN01Btn">
<button type="button" class="MdBtn03Gn01" id="jsLaunchApp" data-href="line://shop/detail/8072"> Open LINE App
</button>
<button type="button" class="MdBtn03Gr01" id="jsInstallApp" data-href="itms-apps://itunes.apple.com/app/line-for-ipad/id913855602"> Download LINE App
</button>
</div>
</section>
<!--/LyContents--></div>
<!--/CONTENTS-AREA-->
<!--/SCRIPT-->
</body>
</html>

測試 Android 平台 Header:

curl -H 'User-Agent: Mozilla/5.0 (Linux; U; Android 4.1.1; en-gb; Build/KLP) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30' http://line.me/R/shop/detail/8072

取得結果:

<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">
<title>LINE</title>
<link rel="stylesheet" href="//scdn.line-apps.com/n/line_urlscheme/css/line_urlscheme_1464238694.css">
<script src="//scdn.line-apps.com/n/line_urlscheme/js/lc.line.scheme_1464238694.js"></script>
</head>

<body>
<!--CONTENTS-AREA-->
<div class="LyContents" role="main">
<section class="MdCMN01Cont">
<p class="mdCMN01Desc">
Open the LINE app to continue.

</p>
<div class="mdCMN01Img"><img src="//scdn.line-apps.com/n/line_urlscheme/img/img_line_160830.png" alt="LINE" width="75" height="75"></div>
<div class="mdCMN01Btn">
<button type="button" class="MdBtn03Gn01" id="jsLaunchApp" data-href="intent://shop/detail/8072#Intent;scheme=line;action=android.intent.action.VIEW;category=android.intent.category.BROWSABLE;package=jp.naver.line.android;end"> Open LINE App
</button>
<button type="button" class="MdBtn03Gr01" id="jsInstallApp" data-href="market://details?id=jp.naver.line.android"> Download LINE App
</button>
</div>
</section>
<!--/LyContents--></div>
<!--/CONTENTS-AREA-->
<!--/SCRIPT-->
</body>
</html>

Mobile Browser會將所有與 User Agent(簡稱 UA)相關的資訊包含在User Agent String裡(平台、OS、瀏覽器、版本等),除了可以使用javascript偵測User Agent String裡的關鍵字,也可以在Web Server 上處理。

熱門行動的裝置的User Agent String:

iPad:

Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10

iPhone:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16

Chrome for Android Phone:

Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev> (KHTML, like Gecko) Chrome/<Chrome Rev> Mobile Safari/<WebKit Rev>

Chrome for Android Tablet UA:

Mozilla/5.0 (Linux; <Android Version>; <Build Tag etc.>) AppleWebKit/<WebKit Rev>(KHTML, like Gecko) Chrome/<Chrome Rev> Safari/<WebKit Rev>

  • Phone pattern: 'Android' + 'Chrome/[.0-9]* Mobile'
  • Tablet pattern: 'Android' + 'Chrome/[.0-9]* (?!Mobile)'

電腦版 Chrome 41.0.2228.0 在 Windows 的 User Agent string:

Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36

電腦版 Chrome 在 Mac OS X 的 User Agent string:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36

 

相關文章:History of the browser user-agent string
為什麼瀏覽器 user-agent string 總是包含 Mozilla/5.0 ?
http://webaim.org/blog/user-agent-string-history/

下指令:
curl -v -H ‘User-Agent: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36’ http://line.me/R/shop/detail/8072

執行結果:

 < HTTP/1.1 302 Moved Temporarily
 < Server: nginx
 < Date: Thu, 02 Mar 2017 20:23:57 GMT
 < Content-Type: text/html
 < Content-Length: 154
 < Connection: keep-alive
 < Location: http://line.me
 < Cache-Control: no-cache

網址移動到 http://line.me , 應該是不支援的意思。

 

結論:

  • Android系統的行動裝置幾乎都有“Android”字眼,且多搭配webkit引擎的瀏覽器,所以可用這兩者作為關鍵字。
  • 而Apple產品的User Agent String幾乎都包含iPhone字眼。

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *