Google Fuzzy Search
Project description
Google Fuzzy Search
is a tool for fuzzy find for the result of searching with googler.
⚠ Warning
If you get the following response, stop using it.
This is an error from google
. So you can't do anything with googler. Please use it after a while.
$ googler --json --count 100 python | gfzs
Error: Expecting value: line 1 column 2 (char 1)
Input data: [ERROR] Connection blocked due to unusual activity. THIS IS NOT A BUG, please do NOT report it as a bug unless you have specific information that may lead to the development of a workaround. You IP address is temporarily or permanently blocked by Google and requires reCAPTCHA-solving to use the service, which googler is not capable of. Possible causes include issuing too many queries in a short time frame, or operating from a shared / low reputation IP with a history of abuse. Please do NOT use googler for automated scraping.
To avoid such problems, it is better not to set googler's count option
.
We are not responsible if you ignore the advice and block your IP. please note that.
🐍 Install
pip install gfzs
😎 Demo
seeing is believing.
You can easily try what kind of app it is.
gfzs demo
🌍 Environment
- python3 (over Python 3.6.1)
- poetry
📖 Usage
Initialize first. A configuration file (.gfzsrc
) is created in your home directory.
$ gfzs init
Initialize config in /Users/yukihirop/.gfzsrc
Next, Prepare json with title
, url
and abstract
as keys and pass it.
For Example, Assuming that data.json is as follows.
data.json
[
{
"abstract": "Rustは非常に高速でメモリ効率が高くランタイムやガベージコレクタがないため、パフォーマンス重視のサービスを実装できますし、組込み機器上で実行したり他の言語との調和も簡単にできます。 信頼性. Rustの豊かな型システムと所有権 ...",
"matches": [
{
"offset": 0,
"phrase": "Rust"
},
{
"offset": 97,
"phrase": "Rust"
}
],
"title": "Rustプログラミング言語",
"url": "https://www.rust-lang.org/ja"
},
{
"abstract": "Rust(ラスト)はMozillaが支援するオープンソースのシステムプログラミング言語である。 Rust言語は速度、並行性、安全性を言語仕様として保証するC言語、C++に代わるシステムプログラミング(英語版)に適したプログラミング言語を ...",
"matches": [
{
"offset": 0,
"phrase": "Rust"
},
{
"offset": 48,
"phrase": "Rust"
}
],
"metadata": "型付け: 静的型付け、強い型付け、型推論、構造... | 登場時期: 2010年7月7日 | ライセンス: Apache-2.0、MIT License | 影響を受けた言語: Alef、C++、C Sharp、Cyclon...",
"title": "Rust (プログラミング言語) - Wikipedia",
"url": "https://ja.wikipedia.org/wiki/Rust_(%E3%83%97%E3%83%AD%E3%82%B0%E3%83%A9%E3%83%9F%E3%83%B3%E3%82%B0%E8%A8%80%E8%AA%9E)"
}
]
Pipe as standard input
cat data.json | gfzs
🚀 Practical Example (using googler)
Search python articles on github.com
googler --json --site github.com python | gfzs
Display only those with a score of 50 or more in the search results
Please see here for score.
googler --json --site github.com python | gfzs -s 50
⚙ Configure
The default setting is the following file, and each key can enter the following values.
After changing the settings, you can check if the settings are correct with the valid
command.
$ gfzs valid
Config is valid
~/.gfzsrc
{
"view": {
"footer": {
"message": "QUERY>",
"color": {
"message": {
"text": 2,
"background": 0,
"style": "normal"
},
"hline": {
"text": 7,
"background": 0,
"style": "normal"
}
}
},
"header": {
"color": {
"hline": {
"text": 7,
"background": 0,
"style": "normal"
}
}
},
"search_result": {
"color": {
"index": {
"text": 6,
"background": 0,
"style": "normal"
},
"title": {
"text": 2,
"background": 0,
"style": "bold"
},
"url": {
"text": 3,
"background": 0,
"style": "link"
},
"abstract": {
"text": 7,
"background": 0,
"style": "normal"
},
"markup_partial": {
"text": 2,
"background": 5,
"style": "normal"
},
"markup_char": {
"text": 1,
"background": 0,
"style": "normal"
}
}
},
"paging": {
"color": {
"common": {
"text": 2,
"background": 0,
"style": "bold"
}
}
}
}
}
key | description | value |
---|---|---|
text | curses color | 0〜7 |
background | curses color | 0〜7 |
style | text style | "normal", "link", "bold" |
curses color
number | description |
---|---|
0 |
curses.COLOR_BLACK |
1 |
curses.COLOR_RED |
2 |
curses.COLOR_GREEN |
3 |
curses.COLOR_YELLOW |
4 |
curses.COLOR_BLUE |
5 |
curses.COLOR_MAGENTA |
6 |
curses.COLOR_CYAN |
7 |
curses.COLOR_WHITE |
⚙ Environment Variable
name | description |
---|---|
DEBUG |
You will be able to use the debug module. |
EDITOR |
Set the command to open the editor. |
💪 Development
First, create a virtual environment.
$ python3 -m venv .venv
$ poetry shell
$ poetry install
$ python3 gfzs/controller.py
or
$ cat fixtures/rust.json | python3 -m gfzs
or
$ cat fixtures/rust.json | bin/gfzs
💪 Development (Check Partial View)
search_result
$ python3 gfzs/views/search_result.py
footer
$ python3 gfzs/views/footer.py
header
$ python3 gfzs/views/header.py
not_found
$ python3 gfzs/views/not_found.py
paging
$ python3 gfzs/views/paging.py
📚 Reference
I really referred to the implementation of the following repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.