The following quickie command line application formats a list of questions obtained from search results.
###Requirements:
Usage:
- Retrieve a list of questions from the API (from the
/questions/{ids}
or/search
route, maybe others) into one or more JSON file. - Call the script on the JSON file(s).
- Copy-paste the output into a post on
meta.*
.
Example:
wget -O list+recommendations-1.json 'http://api.scifi.stackexchange.com/1.1/search?tagged=list;recommendations'
wget -O list+recommendations-2.json 'http://api.scifi.stackexchange.com/1.1/search?tagged=list;recommendations&page=2'
wget -O list+recommendations-3.json 'http://api.scifi.stackexchange.com/1.1/search?tagged=list;recommendations&page=3'
show_questions https://scifi.stackexchange.com/ list+recommendations-?.json
Result: this meta.scifi question, e.g.
The script:
#! /usr/bin/env perl
## Usage: $0 http://stackoverflow.com/ questions.json ...
use strict;
use warnings;
use File::Slurp qw(slurp);
use JSON;
my $root = $ARGV[0]; shift; $root =~ s!/$!!;
my @questions =
sort {$a->{question_id} <=> $b->{question_id}}
map {@{$_->{questions}}}
map {from_json(slurp($_))} @ARGV;
foreach my $q (@questions) {
my $title = $q->{title}; $title =~ s/([*<>\[\]\`\\])/\\$1/g;
my $url = "$root/questions/" . $q->{question_id};
my $answers = $q->{answer_count};
print "* [$title]($url) ($answers)\n";
}