Skip to content
This repository has been archived by the owner on Mar 5, 2022. It is now read-only.

Commit

Permalink
Support Google News.
Browse files Browse the repository at this point in the history
Signed-off-by: Arun Prakash Jana <[email protected]>
  • Loading branch information
jarun committed Aug 30, 2015
1 parent 5ab8c8c commit 5875809
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Modified (2015) by Arun Prakash Jana &lt;[email protected]&gt;
<pre>Usage: google [OPTIONS] KEYWORDS...
Options
-s N start at the N<sup>th</sup> result
-n N shows N results (default 10)
-n N show N results (default 10)
-N show results from news section
-c SERV country-specific search (Ref: https://en.wikipedia.org/wiki/List_of_Google_domains)
Added TLDs: ar, au, be, br, ca, ch, cz, de,
es, fi, fr, id, in, it, jp, kr, mx, nl, ph,
Expand Down Expand Up @@ -52,6 +53,9 @@ To remove, run:

# News

>**31 Aug, 2015**
> - Google News support
>**30 Aug, 2015**
> - Reformat country/domain specific search code. 28 domains supported now
> - Add switch for debug logs
Expand Down
8 changes: 7 additions & 1 deletion google
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ conn = None # Use a single global connection during navigation
nav = "n" # For user navigation
server = "www.google.com" # For country-specific search
debug = False # Print debug logs
news = False # Read news

# Classes
class GoogleParser(HTMLParser.HTMLParser):
Expand Down Expand Up @@ -182,6 +183,7 @@ def usage():
print("Options")
print(" -s N start at the Nth result")
print(" -n N show N results (default 10)")
print(" -N show results from news section")
print(" -c SERV country-specific search (refer man or project page for details)")
print(" -l LANG display in language LANG, such as fi for Finnish")
print(" -C disable color output")
Expand Down Expand Up @@ -218,7 +220,7 @@ if len(sys.argv) < 2:
usage()

try:
optlist, keywords = getopt(sys.argv[1:], "s:n:c:l:f:t:dCj")
optlist, keywords = getopt(sys.argv[1:], "s:n:c:l:f:t:NCjd")
for opt in optlist:
if opt[0] == "-s":
# Option -s N
Expand All @@ -232,6 +234,8 @@ try:
print("google: option -n needs an integer")
sys.exit(1)
num = opt[1]
elif opt[0] == "-N":
news = True
elif opt[0] == "-c":
server = serverURL(opt[1])
elif opt[0] == "-l":
Expand Down Expand Up @@ -272,6 +276,8 @@ if start is not None:
url += "start=" + start + "&"
if num is not None:
url += "num=" + num + "&"
if news:
url += "tbm=nws&"
if lang is not None:
url += "hl=" + lang + "&"
if duration is not None:
Expand Down
3 changes: 3 additions & 0 deletions google.1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ Show
.I N
results (default 10).
.TP
.BI \-N
Show results from news section.
.TP
.BI \-c " SERV"
Country-specific search [added TLDs: ar, au, be, br, ca, ch, cz, de, es, fi, fr, id, in, it, jp, kr, mx, nl, ph, pl, pt, ro, ru, se, tw, ua, uk].
.TP
Expand Down

0 comments on commit 5875809

Please sign in to comment.