}
use IO::File;
-use URI::ParamMunge;
-use LWP::UserAgent;
+use URI;
+use WWW::Mechanize;
# XXX parse config file
name => '${search}_results_genecard',
terms => '-',
genecard_site => 'http://bioinfo.weizmann.ac.il/cards-bin/',
- genecard_search_url => 'cardsearch.pl?search_type=keyword%28s%29&search=complement',
+ genecard_search_url => 'cardsearch.pl?search_type=kwd&mini=no&speed=fast&matches=999999',
);
GetOptions(\%options,'format|f=s','database|b=s','name|n=s',
$terms = new IO::File $options{terms}, 'r' or die "Unable to open file $options{terms}: $!";
}
-my $ua = new LWP::UserAgent(agent=>"DA_get_harvester_results/$REVISION");
-
#For every term
while (<$terms>) {
# Get uids to retrieve
chomp;
my $search = $_;
- my $url = uri_param_munge($options{genecard_site}.$options{genecard_search_url},
- {search => $search,
- },
- );
- my $request = HTTP::Request->new('GET', $url);
- my $response = $ua->request($request);
- $response = $response->content;
- my @result_urls = $response =~ m#<a\s+href=\"(carddisp?[^\"]+)\"\s*>\s+<b>Display</b>\s*<font size=-1>\s*<br>\s*the<b>\s*complete#sg;
-
+ my $uri = URI->new($options{genecard_site}.$options{genecard_search_url});
+ $uri->query_form($uri->query_form(),
+ search => $search,
+ );
+ my $url = $uri->as_string;
+ my $mech = WWW::Mechanize->new(agent=>"DA_get_harvester_results/$REVISION");
+ $mech->get($url);
+ my $response = $mech->content();
+ my @result_urls = $response =~ m#<a\s+target\=\'card\'\s+href=\"(carddisp\.pl\?[^\"]+)\"\s*>#sg;
my $dir_name = eval qq("$options{name}") or die $@;
- mkdir("$options{dir}/$dir_name") or die "Unable to make directory $options{dir}/$dir_name $!";
+ if (not -d "$options{dir}/$dir_name") {
+ mkdir("$options{dir}/$dir_name") or die "Unable to make directory $options{dir}/$dir_name $!";
+ }
# Get XML file
my @current_urls;
while (@current_urls = map{$options{genecard_site}.$_} splice(@result_urls,0,30)) {
my $url = $uri->as_string;
my $queue = Thread::Queue->new();
my $dir_name = eval qq("$options{name}") or die $@;
- mkdir("$options{dir}/$dir_name") or die "Unable to make directory $options{dir}/$dir_name $!";
+ if (not -d "$options{dir}/$dir_name") {
+ mkdir("$options{dir}/$dir_name") or die "Unable to make directory $options{dir}/$dir_name $!";
+ }
my $wget_thread = threads->new(\&get_url,"$options{dir}/$dir_name",$queue);
push @threads,$wget_thread;
keywords => 0,
);
-GetOptions(\%options,'keyword|k=s','dir|D=s','debug|d+','help|h|?','man|m');
+GetOptions(\%options,'keyword|k=s','dir|D=s','debug|d+','help|h|?','man|m',
+ 'keywords',
+ );
pod2usage() if $options{help};
if (@ARGV != 1) {
pod2usage("If the --keywords option is used, exactly one argument (the keyword) must be passed");
}
- $option{dir} = "$ARGV[0]_results_harvester";
+ $options{dir} = "$ARGV[0]_results_harvester";
}