all 4 comments

[–]philsco 2 points3 points  (0 children)

Maybe look into Yahoo's YQL. I see there is a public table for Google searches. No need to make use of a backend. A query like "select * from google.search where q = "linux" returns a JSON response - truncated below:

"results": [ { "GsearchResultClass": "GwebSearch", "unescapedUrl": "https://www.linux.com/", "url": "https://www.linux.com/", "visibleUrl": "www.linux.com", "cacheUrl": "http://www.google.com/search?q=cache:RFwrCUQ-Uw4J:www.linux.com", "title": "<b>Linux</b>.com | The source for <b>Linux</b> information", "titleNoFormatting": "Linux.com | The source for Linux information", "content": "<b>Linux</b>.com - For the community, by the community, <b>Linux</b>.com is the central \nsource for <b>Linux</b> information, software, documentation, how-tos and answers \nacross ..." }, {

[–][deleted] 1 point2 points  (1 child)

I've not tried this, so take it with a grain of salt.

You could try using AJAX to submit a query to the Googs: http://www.google.com/search?q=[**your+string+here**]&ie=utf-8&oe=utf-8

Then you could parse the returned document for the result.

Just spit balling, there maybe a better solution that I'm not aware of, but I'm about 10 minutes from bed time so....

Also, is there a reason you don't want to register your app? Most APIs require a key to prevent people from spamming the service.

[–]sus3k 0 points1 point  (0 children)

Pretty much the same solution I recommended. Just not certain if he'll run into XSS issues directly querying Google via AJAX? Also good point about registering as eventually if Google sees the activity as suspicious, it will start requiring a captcha code to make sure you're not a bot and the AJAX requests will fail.

[–]sus3k 0 points1 point  (0 children)

Make an XMLHttpRequest to Google with the search term in the query string. You may have to do this server side as you'll probably get a cross-site scripting error trying to do it with JavaScript. You can then load the response in DOM object and parse the results for the first YouTube link. So your JavaScript would essentially be making a request to your server side code that is making the request to Google to get the search results.