Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Perl: the Markov chain saw
 
PerlMonks  

Re: Passing Values to a webpage and retrieving an answer

by Marshall (Prior)
on Apr 30, 2012 at 22:23 UTC ( #968171=note: print w/ replies, xml ) Need Help??


in reply to Passing Values to a webpage and retrieving an answer

The type of response that you are going to get is the webpage source code - that's the code that your browser would run to present the user display. The LWP family of routines essentially emulates a browser (the server cannot tell the difference). So,

my $response = $ua->get('http://sentimentanalyzer.appspot.com');
would suffice for that purpose. This "input=>te" means nothing. In order to send a response to this server, you need to use the POST method to send your text back (based upon the received webpage) and specify the action. This will have the effect of clicking on the "submit" button.

While looking at this page, I learned of this "curl" freeware program. They give an example of how to use it with their page. That looks pretty straight-forward to me for this simple application. But I have never used Curl.

If this is all you need to do, I would follow their suggestion and use this freeware Curl thing. I've written a number of these LWP programs and often spent hours or even days figuring out the right "incantation".

Anyway, if you just need this one website's function, I would install and run Curl, my $result = `curl ...whatever...` . Get that working, then tackle a more general solution with Perl's various LWP methods including of course LWP and Mechanize - this can get very complicated!

I would concentrate on making your first Perl web program a success rather than having to know/learn a lot of sophisticated stuff that is not necessary for the job at hand.

Update: Just tried this advice, and although it sounded good from the website, their main mirror site is having troubles now and I was unable to download a "unzip and go, i.e. a pre-built" Windows version of this thing. So evidently this may take more work than the main website claims.


Comment on Re: Passing Values to a webpage and retrieving an answer
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968171]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2013-05-23 22:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best material for plates (tableware) is:









    Results (493 votes), past polls