Skip to content

Instantly share code, notes, and snippets.

@marked
Last active May 13, 2019 03:48
Show Gist options
  • Save marked/5b71329c8149374705218c8ed920db64 to your computer and use it in GitHub Desktop.
Save marked/5b71329c8149374705218c8ed920db64 to your computer and use it in GitHub Desktop.
Grab URL, once for each UA

How to get started

  1. download the zip
  2. unzip downloaded file
  3. cd to unzipped dir
  4. chmod +x test-ua.pl
  5. Run ./test-ua.pl www.google.com

Depends on: perl and wget

Add more browsers by editing/adding to browsers.txt

chrome-win-60:Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 Safari/537.36
wget-1.20:Wget/1.20.3 (linux-gnu)
#!/usr/bin/perl
use warnings;
use strict;
if (! defined($ARGV[0])){
die "Usage:\n$0 http://example.com/\n";
}
my $url = $ARGV[0];
open(UA_FH,"< browsers.txt") || die "Create UA file 'browsers.txt' with lines of \$BrowserName:\$UseragentString";
while(my $line = <UA_FH>) {
chomp $line;
my ($browser_name, $browser_ua) = split(":", $line);
system("wget -U '$browser_ua' -O $browser_name.html $url ");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment