With a given url like www.example.com i want to extract the apple touch icon by e.g. searching the dom for this attribute:
<link rel="apple-touch-icon" href="touch-icon-iphone.png">
The Problem is that example.com doesn't provide this tag on the normal website, just on the mobile m.example.com website. I think they use server side device detection and add this tag only on mobile devices. Any idea on how i could get this icons on such websites?
If
example.comhas am.example.commobile version, they are probably redirecting mobile phone users using User Agent sniffing.The website's server basically looks at your request's
User-AgentHTTP header and matches it against a set of values to detect mobile browsers. Here is an example of how it is done in Apache:The good news is you can fool the server into serving you
m.example.comby setting the header yourself. Here is an example with curl :The first one will retrieve the HTML for facebook.com, the second one sets the User-Agent header to the iPhone's value. Note that we must use the -L option in order for curl to follow the redirect from
facebook.comtom.facebook.com.