Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,22 @@ For Windows: Command Line Prompt
1. pySearch can be used by using `pySearch -s <search query>`

#### Command Line Arguments
<<<<<<< HEAD
<ol>
<li> -s takes query to search</li>
<li> -e changes name or alias of search engine and sets it to as search engine for session </li>
<li> -d changes to domain extension </li>
<li> -h will provide description of command line arguments </li>
<li> -b changes the browser to search in. If an invalid browser is selected, a list of valid ones will be displayed.</li>
</ol>
=======
- `-s` takes query to search
* multiple searches can be performed with multiple `-s` delimiters
* use quotes(" ") if searches contain `-s`
- `-e` changes name or alias of search engine and sets it to as search engine for session
- `-d` changes to domain extension
- `-h` provides a description of each command line argument
>>>>>>> upstream/master

## Built With
Python 3
Expand Down
2 changes: 1 addition & 1 deletion pySearch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#jrkong's command line searcher
# jrkong's command line searcher
import argparse
from search import Search

Expand Down
3 changes: 3 additions & 0 deletions search.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import urllib
import webbrowser
from urllib.parse import quote

class Search:
def __init__(self, searchIn = None, engineIn = "google", domainIn = "ca"):
Expand All @@ -23,6 +24,8 @@ def setDomain(self, domainIn):

#set search Query
def setQuery(self, searchIn):
for term in range(len(searchIn)):
searchIn[term] = quote(searchIn[term].encode('utf8'))
self.searchRaw = searchIn
#end of setQuery

Expand Down
13 changes: 13 additions & 0 deletions tests/test_search.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
from urllib.parse import quote

from ..search import Search

Expand All @@ -8,3 +9,15 @@ def test_builtLink():
tmpSearch.setDomain("com")
tmpSearch.setQuery(["test", "query"])
assert tmpSearch.buildLink() == "http://www.amazon.com/s/keywords=test%20query"

def test_encoding():
tmpSearch = Search()
tmpSearch.setEngine("amazon")
tmpSearch.setDomain("com")
unsafe = "A <string> with {unsafe chars"
unsafe = unsafe.split()
safe = unsafe
for term in range(len(safe)):
safe[term] = quote(safe[term].encode('utf8'))
tmpSearch.setQuery(unsafe)
assert tmpSearch.searchRaw == safe