cormanaz has asked for the wisdom of the Perl Monks concerning the following question:
When I run this I get:my $text = qq("Researchers from the University of Minnesota's Institut +e on the Environment looked at 17 key crops that produce 86 percent o +f the world crop calories.); my $ua = LWP::UserAgent->new(); my $response = $ua->post( 'http://query.yahooapis.com/v1/public/yql', ['q' => "select * from contentanalysis.analyze where text='".$text +."'"] ); print $response->content();
So it doesn't like the apostrophe in the query. When I take out the apostrophe, it works like it's supposed to. Since it's a SQL-like query, I tried using double apostrophes, like you would to escape a query string in SQL, and that produced the same error. So I tried URI::Escape on the string. That yields response status of OK, but no contents in the results, i.e.<?xml version="1.0" encoding="UTF-8"?> <error xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:lang=" +en-US"><description>Query syntax error(s) [line 1:96 missing EOF at ' +s']</description></error>
Anyone know how I can get this working?<?xml version="1.0" encoding="UTF-8"?> <query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count= +"0" yahoo:created="2014-07-19T19:41:26Z" yahoo:lang="en-US"><results/ +></query><!-- total: 177 --> <!-- engine4.yql.ne1.yahoo.com -->
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to transmit text to Yahoo Content Analysis
by Your Mother (Archbishop) on Jul 19, 2014 at 22:51 UTC | |
|
Re: How to transmit text to Yahoo Content Analysis
by roboticus (Chancellor) on Jul 19, 2014 at 22:53 UTC | |
|
Re: How to transmit text to Yahoo Content Analysis
by thomas895 (Deacon) on Jul 19, 2014 at 21:48 UTC | |
|
Re: How to transmit text to Yahoo Content Analysis
by Your Mother (Archbishop) on Jul 20, 2014 at 20:35 UTC |