-
-
Notifications
You must be signed in to change notification settings - Fork 534
Number of search results #144
Comments
Would you mind raising a PR? And this should show just above the omniprompt only in the first page of a search. |
I recall thinking about this and decided it was not worth the complexity.
Instead of requesting a feature from googler then parsing it from googler's output, here's a much simpler and much more direct approach — a one-liner shell script (assuming English language and GNU grep; easy to adapt otherwise): $ cat google-result-count
#!/bin/sh
curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" -sSL "https://www.google.com/search?q=$1" | grep -Po "(?<=About )[0-9,]+(?= results)" | tr -d ,
$ ./google-result-count google
10520000000
$ ./google-result-count apple
2120000000
$ ./google-result-count microsoft
1080000000 Feel free to contribute the feature though. |
By the way here's a more robust version with proper quoting and supporting multiple arguments: #!/bin/sh
for keyword; do
safe_keyword="$(python3 -c 'import urllib.parse, sys; print(urllib.parse.quote_plus(sys.argv[1]))' \""$keyword"\")"
curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" -sSL "https://www.google.com/search?q=$safe_keyword" | grep -Po "(?<=About )[0-9,]+(?= results)" | tr -d ,
done
|
I decided to have a few lines in bash indeed, wget with user agent string works as well. If it's complex to add to googler itself, don't do it of course! It's just a feature request. |
I investigated the case today and the parser does need to go through some hacky modifications OR some extra parsing per page (to avoid, again, hacks). I believe we can safely avoid this. Closing the issue. |
What does
|
Are you running on Mac OSx? -P is no longer supported
ᐧ
…On Mon, Jan 22, 2018 at 1:09 PM, Rishabh Tayal ***@***.***> wrote:
What does -Po option do in grep? I am getting error when running the
script:
#!/bin/sh
for keyword; do
safe_keyword="$(python3 -c 'import urllib.parse, sys; print(urllib.parse.quote_plus(sys.argv[1]))' \""$keyword"\")"
curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" -sSL "https://www.google.com/search?q=$safe_keyword" | grep -Po "(?<=About )[0-9,]+(?= results)" | tr -d ,
done
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#144 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABHJy5bJgSD37jGUqNnrCZtXngZADcZJks5tNM7IgaJpZM4Kyywn>
.
|
-P (for PCRE) was never supported by BSD grep. Read the man page of GNU grep. |
Meant to include this page
https://stackoverflow.com/questions/16658333/grep-p-no-longer-works-how-can-i-rewrite-my-searches
ᐧ
…On Mon, Jan 22, 2018 at 1:23 PM, Zhiming Wang ***@***.***> wrote:
-P (for PCRE) was never supported by BSD grep. Read the man page of GNU
grep.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#144 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABHJy9ExnmFwT2T3sA2vqYxXh4ba4rOiks5tNNILgaJpZM4Kyywn>
.
|
@fredzannarbor I am running on Mac OSX. I am not a shell expert or expert with |
@RishabhTayal Try creating a different new issue, this one is closed and not related to yours. |
@RishabhTayal Use sed: curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" -sSL "https://www.google.com/search?q=hello" | \
/usr/bin/sed -nE 's/.*About ([0-9,]+) results.*/\1/p' or perl: curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" -sSL "https://www.google.com/search?q=hello" | \
perl -nle 'print "$1" if /(?<=About )([0-9,]+)(?= results)/' or even a double grep: curl -A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" -sSL "https://www.google.com/search?q=hello" | \
grep -Eo 'About [0-9,]+ results' | grep -Eo '[0-9,]+' Of course there's also gawk, but I'm not sure /usr/bin/awk on macOS supports capture groups. Seriously though, this is not a googler issue, and the issue tracker is not a discussion forum. This kind of questions should be directly to StackOverflow. If you want to learn text editing with grep, sed, awk, etc., there are plenty of good starting points, a few random ones off the top of my head: http://www.grymoire.com/Unix/sed.html And I don't need to introduce Perl resources (maybe start with The Llama Book). |
A feature request.
Is it possible to list the number of search results in the output? I'm often using it to define how popular a brand is. And as a non-native speaker on how to spell a word. :-)
Google always displays this as something like "About 2.620.000.000 results (0,53 seconds)" which is never accurate, but good enough for me.
The text was updated successfully, but these errors were encountered: