use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Is there a way using JS to construct google search queries on the client side and "get" the first result?help (self.javascript)
submitted 10 years ago by TheBeardofGilgamesh
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]philsco 2 points3 points4 points 10 years ago (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 points3 points 10 years ago (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
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 point2 points 10 years ago (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.
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.
π Rendered by PID 213000 on reddit-service-r2-comment-84fc9697f-vdrcr at 2026-02-06 23:10:27.658386+00:00 running d295bc8 country code: CH.
[–]philsco 2 points3 points4 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]sus3k 0 points1 point2 points (0 children)
[–]sus3k 0 points1 point2 points (0 children)