Add a simple name suggestion based on Hyperdia queries
This commit is contained in:
parent
06e31af6ee
commit
4ad209cc5c
1 changed files with 27 additions and 0 deletions
27
hyperdia_suggest.py
Executable file
27
hyperdia_suggest.py
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
HYPERDIA_SUGGEST_URL = "http://www.hyperdia.com/en/cgi/suggest/en/nsnl.cgi"
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("name", help="Name or partial name to search for")
|
||||||
|
|
||||||
|
options = parser.parse_args()
|
||||||
|
|
||||||
|
req = requests.get(HYPERDIA_SUGGEST_URL, params=options.name.upper()
|
||||||
|
+ "_null")
|
||||||
|
|
||||||
|
if req.status_code == 200:
|
||||||
|
print("Possible matches:")
|
||||||
|
for item in req.text.split(","):
|
||||||
|
print(item)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
Loading…
Add table
Reference in a new issue