Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #9 - Ensure that domain works #20

Open
wants to merge 9 commits into
base: master
from
@@ -1,6 +1,8 @@

import urllib
import webbrowser
import platform
import subprocess

class Search:
def __init__(self, searchIn = None, engineIn = "google", domainIn = "ca"):
@@ -41,9 +43,38 @@ def buildLink(self):
#end of link building

def openBrowser(self):
webbrowser.open_new_tab(self.url)
pingSuccess = self.ping()
if pingSuccess == "invalid":
print("The url is invalid, unable to find new url")
else:
if pingSuccess == "domain found":
print("The url is invalid, opened "+self.url+" instead!")
This conversation was marked as resolved by alexander-ponomaroff

This comment has been minimized.

Copy link
@jrkong

jrkong Dec 18, 2018

Owner

Missing whitespaces around the arithmetic operator (Flake8 E226)

webbrowser.open_new_tab(self.url)
#end of openBrowser()

def ping(self):

popularDomains = ["ca", "com", "de", "cn", "net", "uk", "org", "info",
"nl", "eu", "ru"]

if platform.system().lower() == "windows":
command = ["C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe", "Invoke RestMethod", "-Uri", self.url]
else:
command = ["curl", "-X", "POST", self.url]

if subprocess.call(command, shell = True) != 0:
for dom in popularDomains:

self.url = "http://www." + self.engine + "." + dom + self.searchString + self.searchQuery
self.domain = dom
command[3]= self.url
This conversation was marked as resolved by alexander-ponomaroff

This comment has been minimized.

Copy link
@jrkong

jrkong Dec 18, 2018

Owner

Missing whitespace around this operator (Flake8 E225)


if subprocess.call(command) == 0:
return "domain found"
return "invalid"
else:
return "valid"

def handleArgs(self, args):
if args.engine is not None:
self.setEngine(args.engine[0])
@@ -57,4 +88,4 @@ def handleArgs(self, args):
self.openBrowser()
#end of handleArgs

#end of Query
#end of Query
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.