Build a script in Perl or Ruby. The purpose of this script is to determine if the web page has special logic to handle display on mobile phone screens (such as serving different HTML or using special CSS).
The script will take input from STDIN. The input will be a list of target URLs (with one URL per line). For each target URL perform the following steps:
1) Download a temporary copy of the web page with the User Agent string set to emulate Internet Explorer 9 and follow redirects (if any)
2) Calculate the following information about the HTML file returned
a) URL of the downloaded file (different from the target if redirects were encountered)
b) Count of characters in the file
c) Count of tags in the file
d) Determine whether the file includes a line with the string "@media" and also contains either "max-device-width:" OR "max-width:"
3) Download a temporary copy of each of the CSS files referenced in the HTML file
4) Calculate whether the following is true for ANY of the CSS files
a) Determine whether the file includes a line with the string "@media" and also contains either "max-device-width:" or "max-width:" (this is called a media query)
5) Download the target URL with the User Agent string set to emulate an iPhone 5
6) Calclulate the following information about the HTML file returned
a) URL of the downloaded file
b) Count of characters in the file
c) Count of tags in the file
7) Write a line to STDOUT (see output format mentioned below) with the information that was calculated above.
8) Delete any temporary files downloaded
-------
OUTPUT LINE FORMAT:
The output file will have one line per target URL. The line consists of tab delimited (\t) text. Below is a list of the items on each row:
1) URL of the downloaded file when user agent is IE9
2) Count of characters in the HTML file when user agent is IE9
3) Count of tags in the HTML file when user agent is IE9
4) "MQ" if the file includes the media query line when the user agent is IE9 (otherwise blank)
5) "MQ" if ANY of the linked CSS files contained a media query line when the user agent is IE9 (otherwise blank)
6) URL of the downloaded file when user agent is iPhone 5
7) Count of characters in the HTML file when user agent is iPhone 5
8) Count of tags in the HTML file when the user agent is iPhone 5
I will provide URLs for three web sites to test that the script is working correctly. If it gives correct answers for all 3, I will consider the work complete.
Hello,
I am a Perl scripting expert prepared to complete this task for you.
Please forward your list of test sites.
I will open a PMB to discuss details.