Sanchit R Sanchit R - 7 months ago 33
Bash Question

Script to Mobile-Friendly test

I wanted to write a shell/python script which will check if a website is mobile friendly or not. Using browser this can be easily done by visiting-

https://www.google.com/webmasters/tools/mobile-friendly/?url=<website_addr>


For eg.-

https://www.google.com/webmasters/tools/mobile-friendly/?url=http://facebook.com


I tried fetching the content through
curl,
wget
,
lynx
commands but it did not worked.

How can I do so?

Answer

Solved it myself, with help of @TimberlakeCoding & @MartijnPieters. Here it is-

$ wget -q -O - https://www.googleapis.com/pagespeedonline/v3beta1/mobileReady?url=http://facebo‌​ok.com | grep "\"pass\": true" 

If the exit status code is 0, that means website is mobile friendly else not.

Hope it helps someone! Thanks

Comments