Ask Dave Taylor
  • Facebook
  • Instagram
  • Linkedin
  • Pinterest
  • Twitter
  • YouTube
  • Home
  • YouTube Videos
  • Top Categories
  • Subscribe via Email
  • Ask A Question
  • Meet Dave
  • Home
  • HTML & Web Page Design
  • Add a Google News Search Box to your Site?

Add a Google News Search Box to your Site?

March 18, 2017 / Dave Taylor / HTML & Web Page Design / 1 Comment

I want to add a Google News search box to my Web site and also add some pre-made links. How do I code that?

If you’re so inclined, you can certainly go to Google News, crack open the source code and figure out exactly what’s going on with the search form. That’s the hard way because Google has a lot of smarts in the search boxes, including hints and matches as you type. Those are nice, but complicated.

Instead, I’m a fan of reverse engineering the problem: Figure out the data needed to get the search results page to show matches for a given search and you can unwind the results and identify exactly what’s needed.

To start, therefore, you need to pop onto Google News and do a search. Let’s do a quick news search for actor Chris Evans.

On the Gnews home page, there’s a nice big search box on the top:

google news search box

Type in “Chris Evans”, click on the magnifying glass button and you’ll get the results of the search:

chris evans search results, google news gnews

The important thing here is the URL, actually, not any of the code on the page itself.

A copy and paste reveals this is the full URL of the search results page:

https://www.google.com/search?hl=en&gl=us&tbm=nws&authuser=0&q=chris+evans&oq=chris+evans&gs_l=news-cc.3..43j0l9j43i53.24045.25128.0.28106.11.7.0.4.4.0.119.554.6j1.7.0…0.0…1ac.1.oFS9W6Fg-to

We can unwrap that to the following:

  • hl=en
  • gl=us
  • tbm=nws
  • authuser=o
  • q=chris+evans
  • oq=chris+evans
  • gs_l=really long sequence of stuff

With a bit of experimentation, it turns out that you only need two of these fields: “tbm” to specify that it’s a news query, and “q” to specify the query string. That makes the URL a lot less overwhelming:

https://www.google.com/search?tbm=nws&q=chris+evans

And it gives us everything we need to create a quick and easy HTML search form:

<form method=”get” action=”https://www.google.com/search”>
<input type=”text” name=”q” />
<input type=”hidden” name=”tbm” value=”nws” />
<input type=”submit” value=”search Google News” />
</form>

Let’s give that a whirl, shall we? Here’s the search box, live:

Did you try it? Not glamorous in appearance, for sure, but functional!

Now let’s pretty it up just a bit so it’ll be something you’d want to actually add to your site:

<form method=”get” action=”https://www.google.com/search” style=”border:1px solid black;border-radius:5px;padding:7px;background:#eef;”>
Search Google News: <input type=”text” name=”q” size=”40″ style=”border:1px solid black;padding:3px;border-radius:4px; ” />
<input type=”hidden” name=”tbm” value=”nws” />
<input type=”submit” value=”Go!” style=”border-radius:4px;” />
</form>

And the result, with its groovy blue background:

Search Google News:

That’s it! Just copy the above HTML and make sure you paste it into your page editor in Source or Raw or HTML mode.

And, finally, since you know the short URL format, you can always pre-build any search pattern you’d like by replacing “chris+evans” with something else. Like “captain+america”:

https://www.google.com/search?tbm=nws&q=captain+america

Just make sure you remember to use the “+” to replace any spaces in the search phrase. Then you can also just sprinkle them into your regular text too, like this: Get breaking news about Captain America with a click!

Let’s Stay In Touch!

Never miss a single article, review or tutorial here on AskDaveTaylor, sign up for my fun weekly newsletter!
Name: 
Your email address:*
Please enter all required fields
Correct invalid entries
No spam, ever. Promise. Powered by FeedBlitz
Please choose a color:
Starbucks coffee cup I do have a lot to say, and questions of my own for that matter, but first I'd like to say thank you, Dave, for all your helpful information by buying you a cup of coffee!
form design, google news, google news search, html coding, html form style, reverse engineering, search box, search engine

One comment on “Add a Google News Search Box to your Site?”

  1. Dino says:
    March 21, 2017 at 3:34 pm

    I’d like to know when having a google search bar on ones website does google have any restrictions on the amount of searches one can do?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Recent Posts

  • How Do I Download Movies & Shows from HBOMax.com?
  • Can I Calculate Mortgage Payments with Online Tools?
  • How Do I Find Available Disk Space on my Mac System?
  • How to Identify Plants and Flowers with Google Lens on Android?
  • Windows Security Wants Me to Enable “App & Browser Control”?

On Our YouTube Channel

Acer Chromebook 317 -- Budget 17.3" Laptop -- REVIEW

1More ComfoBuds Mini ANC Earbuds -- REVIEW

Categories

  • AdSense, AdWords, and PPC Help (106)
  • Amazon, eBay, and Online Shopping Help, (161)
  • Android Help (197)
  • Apple iPad Help (144)
  • Apple Watch Help (52)
  • Articles, Tutorials, and Reviews (344)
  • Auto Tech Help (11)
  • Business Advice (199)
  • Chrome OS Help (23)
  • Computer & Internet Basics (763)
  • d) None of the Above (165)
  • Facebook Help (383)
  • Google, Chrome & Gmail Help (177)
  • HTML & Web Page Design (245)
  • Instagram Help (47)
  • iPhone & iOS Help (605)
  • iPod & MP3 Player Help (173)
  • Kindle & Nook Help (92)
  • LinkedIn Help (85)
  • Linux Help (164)
  • Linux Shell Script Programming (86)
  • Mac & MacOS Help (891)
  • Most Popular (16)
  • Outlook & Office 365 Help (24)
  • PayPal Help (69)
  • Pinterest Help (53)
  • Reddit Help (17)
  • SEO & Marketing (81)
  • Spam, Scams & Security (92)
  • Trade Show News & Updates (23)
  • Twitter Help (217)
  • Video Game Tips (66)
  • Web Site Traffic Tips (62)
  • Windows PC Help (915)
  • Wordpress Help (204)
  • Writing and Publishing (72)
  • YouTube Help (46)
  • YouTube Video Reviews (159)
  • Zoom, Skype & Video Chat Help (56)

Archives

Social Connections:

Ask Dave Taylor


Follow Me on Pinterest
Follow me on Twitter
Follow me on LinkedIn
Follow me on Instagram


AskDaveTaylor on Facebook



microsoft insider mvp


This web site is for the purpose of disseminating information for educational purposes, free of charge, for the benefit of all visitors. We take great care to provide quality information. However, we do not guarantee, and accept no legal liability whatsoever arising from or connected to, the accuracy, reliability, currency or completeness of any material contained on this site or on any linked site. Further, please note that by submitting a question or comment you're agreeing to our terms of service, which are: you relinquish any subsequent rights of ownership to your material by submitting it on this site. Our lawyer says "Thanks for your cooperation."
© 2022 by Dave Taylor. "Ask Dave Taylor®" is a registered trademark of Intuitive Systems, LLC.
Privacy Policy - Terms and Conditions - Accessibility Policy