-
Notifications
You must be signed in to change notification settings - Fork 981
Feature to check whether a website is running or not #197
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
Conversation
swapagarwal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The structure looks good overall. 😄
modules/src/__init__.py
Outdated
| 'url', | ||
| 'video', | ||
| 'weather', | ||
| 'webcheck', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we rename it to ping module? It's more intuitive.
modules/src/webcheck.py
Outdated
| strip_list = ['http://','https://','/'] | ||
| for item in strip_list: | ||
| url = url.strip(item) | ||
| page = requests.get('https://isitup.org/'+str(url)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pro Tip: See what happens if you append .json to the end of the URL..
|
Thanks for the feedback! Applied the proposed changes :) |
swapagarwal
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The training for this module is complete. Address the following comments, and this module is good to go! 😄
modules/src/ping.py
Outdated
| @@ -0,0 +1,35 @@ | |||
| import requests | |||
| import json | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed.
modules/src/ping.py
Outdated
| for item in strip_list: | ||
| url = url.strip(item) | ||
| page = requests.get('https://isitup.org/'+url+'.json') | ||
| page = json.loads(page.text) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you see the other modules, the general structure is:
r = requests.get(...)
data = r.json()
modules/src/ping.py
Outdated
| output['error_msg'] = TextTemplate(error_message).get_message() | ||
| output['success'] = False | ||
| return output | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove extra line.
modules/src/ping.py
Outdated
| output['success'] = True | ||
| except: | ||
| error_message = 'There seems to be some problem' | ||
| error_message = '\nPlease ask me something else, like:' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be "+=". Check the below lines too.
modules/src/ping.py
Outdated
| page = json.loads(page.text) | ||
| status = page['status_code'] | ||
| if status == 1: | ||
| txt = orig_url + ' is up!' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use original url here, as that might be misleading. Use the one that we passed in the api call.
modules/src/ping.py
Outdated
| txt = orig_url + ' is up!' | ||
| elif status == 2: | ||
| txt = orig_url + ' seems to be down!' | ||
| else : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we know the status code here? If yes, then we should use that here instead. Any unexpected status codes should result in an error.
modules/src/ping.py
Outdated
| strip_list = ['http://','https://','/'] | ||
| for item in strip_list: | ||
| url = url.strip(item) | ||
| page = requests.get('https://isitup.org/'+url+'.json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spacing around +
modules/src/ping.py
Outdated
| try: | ||
| url = entities['url'][0]['value'] | ||
| orig_url = url | ||
| strip_list = ['http://','https://','/'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a space after comma. Can you explain why the third entry in the list is required?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Coz queries like google.com/ will cause wrong domain name error.
|
Thanks @swapagarwal :) |
|
Congratulations! 🎉 |
Checks whether a web domain is up or not using isitup.org. Needs to learn 'Is xyz.com up', 'xyz.com status'.