Skip to content

Instantly share code, notes, and snippets.

@malteb247
Created September 5, 2022 20:54
Show Gist options
  • Save malteb247/2726438a2b0898da74221d8928841244 to your computer and use it in GitHub Desktop.
Save malteb247/2726438a2b0898da74221d8928841244 to your computer and use it in GitHub Desktop.
sub openurl {
my $url = shift;
my $platform = $^O;
my $cmd;
if ($platform eq 'darwin') { $cmd = "open \"$url\""; } # OS X
elsif ($platform eq 'MSWin32' or $platform eq 'msys') { $cmd = "start \"\" \"$url\""; } # Windows native or MSYS / Git Bash
elsif ($platform eq 'cygwin') { $cmd = "cmd.exe /c start \"\" \"$url \""; } # Cygwin; !! Note the required trailing space.
else { $cmd = "xdg-open \"$url\""; } # assume a Freedesktop-compliant OS, which includes many Linux distros, PC-BSD, OpenSolaris, ...
if (system($cmd) != 0) {
die "Cannot locate or failed to open default browser; please open '$url' manually.";
}
}
my @shopUrls = (
"https://www.probikeshop.com/de/de/search/#KEYWORD#.html",
"https://www.bike24.de/suchergebnis?searchTerm=#KEYWORD#",
"https://www.wigglesport.de/?s=#KEYWORD#",
"https://www.bike-discount.de/de/search?sSearch=#KEYWORD#",
"https://www.bike-mailorder.de/#/dfclassic/query=#KEYWORD#",
"https://www.bike-components.de/de/s/?keywords=#KEYWORD#",
"https://www.tradeinn.com/bikeinn/?products_search%5Bquery%5D=#KEYWORD#",
"https://www.lordgun.de/suche?s=#KEYWORD#",
"https://www.rosebikes.de/search?q=#KEYWORD#",
"https://www.bruegelmann.de/suche/?q=#KEYWORD#",
"https://www.mantel.com/de/search/?q=#KEYWORD#"
);
my $term = join(" ", @ARGV);
foreach ( @shopUrls ) {
my $new = $_ =~ s/#KEYWORD#/$term/r;
openurl $new;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment