aboutsummaryrefslogtreecommitdiff
path: root/challenge-012/feng-chang
diff options
context:
space:
mode:
authorMohammad S Anwar <Mohammad.Anwar@yahoo.com>2019-06-26 17:17:27 +0100
committerGitHub <noreply@github.com>2019-06-26 17:17:27 +0100
commitf8eb67dfb5db0f2a45924bab9774df6197e2f98c (patch)
tree4be14cb709484fe4a3e1ab93c4554495b961c763 /challenge-012/feng-chang
parent7c04dd47b6278d9e14fc1b4aef7649308cf914bd (diff)
parent365a21e5a71bd4db362173a597b0d970e6907ef8 (diff)
downloadperlweeklychallenge-club-f8eb67dfb5db0f2a45924bab9774df6197e2f98c.tar.gz
perlweeklychallenge-club-f8eb67dfb5db0f2a45924bab9774df6197e2f98c.tar.bz2
perlweeklychallenge-club-f8eb67dfb5db0f2a45924bab9774df6197e2f98c.zip
Merge pull request #306 from seaker/mybranch
challeng 014
Diffstat (limited to 'challenge-012/feng-chang')
-rwxr-xr-xchallenge-012/feng-chang/perl5/ch-3.pl24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-012/feng-chang/perl5/ch-3.pl b/challenge-012/feng-chang/perl5/ch-3.pl
new file mode 100755
index 0000000000..ce69036c6b
--- /dev/null
+++ b/challenge-012/feng-chang/perl5/ch-3.pl
@@ -0,0 +1,24 @@
+#!/bin/env perl
+
+use Modern::Perl;
+use WWW::Mechanize;
+use XML::LibXML;
+
+exit unless @ARGV;
+
+my $m = WWW::Mechanize->new() or die "cannot initialize robot\n";
+
+my $base_url = 'http://www.stands4.com/services/v2/syno.php?uid=7082&tokenid=Bnm2q0xAKY2up6qQ';
+my $url = $base_url . "&word=$ARGV[0]&format=xml";
+
+$m->get($url);
+
+my $dom = XML::LibXML->load_xml(string => $m->content);
+foreach my $r ($dom->findnodes('//result')) {
+ say 'term: ', $r->findvalue('./term');
+ say ' definition: ', $r->findvalue('./definition');
+ say ' example: ', $r->findvalue('./example');
+ say ' partofspeech: ', $r->findvalue('./partofspeech');
+ say ' synonyms: ', $r->findvalue('./synonyms');
+ say ' antonyms: ', $r->findvalue('./antonyms');
+}