Skip to content

Commit

Permalink
code beautification and tweaking of script
Browse files Browse the repository at this point in the history
  • Loading branch information
vaibhavsingh97 committed Aug 27, 2017
1 parent c08f7cc commit d4ba06e
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 81 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ Command line tool to open the major social accounts connected to the specfic han
**1.)** Clone the repository by using this link :

```
https://github.com/vaibhavsingh97/StalkPy.git
$ git clone https://github.com/vaibhavsingh97/StalkPy.git
```

### Run

**2.)** Open terminal window there and the type these comands :

```
cd Stalkpy && pip install -r requirements.txt
python StalkPy.py
$ cd Stalkpy && pip install -r requirements.txt
```

User can query as many username

```
$ python StalkPy.py [username1] [username2] ..
```

### Configure
Expand All @@ -44,8 +49,9 @@ python StalkPy.py
- [ ] check list of browser and open accordingly
- [ ] Command line addition of accounts to `Config.json`
- [ ] check the validity of username.
- [ ] handle case if no social account found
- [ ] handle case if no social account found
- [ ] test cross plateform support
- [ ] Add clint support

## Issues

Expand Down
157 changes: 81 additions & 76 deletions StalkPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# @Github username: vaibhavsingh97
# @Website: https://vaibhavsingh97.me
# @Last Modified by: Vaibhav Singh
# @Last Modified Date: 2017-08-27
# @Last Modified Date: 2017-08-28
# @License: MIT License
# you can find your copy of the License
# https://vaibhavsingh97.mit-license.org/
Expand All @@ -24,97 +24,102 @@
import json
import requests
import os
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import webbrowser
import threading
from clint.textui import colored, puts


def head():
"""official banner for StalkPy printed in green color"""
clear()
stalkPyBanner = """
_____ _ _ _ _____
/ ____| | | | | | | | __ \\
| (___ | |_ __ _ | | | | __ | |__) | _ _
\___ \ | __| / _` | | | | |/ / | ___/ | | | |
____) | | |_ | (_| | | | | < | | | |_| |
|_____/ \__| \__,_| |_| |_|\_\ |_| \__, |
__/ |
|___/
- Vaibhav Singh (@ vaibhavsingh97)
- Version 1.0
"""
puts(colored.green(stalkPyBanner))


def clear():
"""for removing the clutter from the screen when necessary"""
os.system('cls' if os.name == 'nt' else 'clear')


def space():
""" for adding one linespace in the console"""
print("")


def notification(flag):
if flag == 1:
puts(colored.red("Error: wrong value entered! Please enter correct value."))
space()
flag = 0
elif flag == 2:
puts(colored.green("Success: Social account found. :)"))
flag = 0
elif flag == 3:
puts(colored.red("No Social accounts found. :("))
flag = 0


def showDoc():
documentation = """
A simple python script to open the major social accounts connected to the
specfic handle. Inspired from [HandleStalker](https://github.com/samanthakem/HandleStalker)
- Simple to use: Built with love so it's easy to use.
- single command will query any number of usernames
- Text Highlighting is cross platform - Supports Linux, MAC, Windows for the terminal based highlighting.
"""
puts(colored.cyan(documentation))
space()


def CleanedLink(url, username):
return "https://www." + url + username
from time import time as timer


class StalkPy():
"""docstring for ."""
"""class for StalkPy tool"""

def __init__(self):
with open('config.json') as data_file:
self.data = json.loads(data_file.read())

def clear(self):
"""for removing the clutter from the screen when necessary"""
os.system('cls' if os.name == 'nt' else 'clear')

def space(self):
""" for adding one linespace in the console"""
print("")

def head(self):
"""official banner for StalkPy printed in green color"""
self.clear()
stalkPyBanner = """
_____ _ _ _ _____
/ ____| | | | | | | | __ \\
| (___ | |_ __ _ | | | | __ | |__) | _ _
\___ \ | __| / _` | | | | |/ / | ___/ | | | |
____) | | |_ | (_| | | | | < | | | |_| |
|_____/ \__| \__,_| |_| |_|\_\ |_| \__, |
__/ |
|___/
- Vaibhav Singh (@ vaibhavsingh97)
- Version 1.0
"""
puts(colored.green(stalkPyBanner))

def showDoc(self):
documentation = """
A simple python script to open the major social accounts connected to the
specfic handle. Inspired from [HandleStalker](https://github.com/samanthakem/HandleStalker)
- Simple to use: Built with love so it's easy to use.
- single command will query any number of usernames
- Text Highlighting is cross platform - Supports Linux, MAC, Windows for the terminal based highlighting.
"""
puts(colored.cyan(documentation))
self.space()

def notification(self, flag):
"""messages for StalkPy tool which will be printed according to the flags"""
if flag == 1:
puts(colored.red("Error: wrong value entered! Please enter correct value."))
space()
flag = 0
elif flag == 2:
puts(colored.green("Success: Social account found. :)"))
flag = 0
elif flag == 3:
puts(colored.red("No Social accounts found. :("))
flag = 0

def CleanedLink(self, url, username):
return "https://www." + url + username

def OpenLinks(self, user):
for social_account_name in self.data:
r = requests.get(CleanedLink(self.data[social_account_name], user))
if r.status_code == 200:
notification(2)
driver = webdriver.Firefox()
driver.get(CleanedLink(self.data[social_account_name], user))
puts(colored.green(social_account_name + ": ") +
colored.blue(CleanedLink(self.data[social_account_name], user)))
r.close()
try:
r = requests.get(self.CleanedLink(
self.data[social_account_name], user))
if r.status_code == 200:
self.notification(2)
webbrowser.open(self.CleanedLink(
self.data[social_account_name], user), new=1)
puts(colored.green(social_account_name + ": ") +
colored.blue(self.CleanedLink(self.data[social_account_name], user)))
r.close()
except Exception as e:
return e


if __name__ == '__main__':
head()
showDoc()
StalkPy().head()
StalkPy().showDoc()
start = timer()
if (len(sys.argv) < 2):
print("usage: \n python StalkPy.py <username1> <username2> ... <usernameN>")
print("usage: \n python StalkPy.py [username1] [username2]...")
StalkPy().space()
puts(colored.red("Exiting..."))
else:
for i in range(1, len(sys.argv)):
space()
StalkPy().space()
puts(colored.magenta("User: %s" % sys.argv[i]))
StalkPy().OpenLinks(sys.argv[i])
t = threading.Thread(target=StalkPy().OpenLinks(sys.argv[i]))
t.start()
t.join()
print("Elapsed Time: %s" % (timer() - start,))
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
codecov==2.0.9
selenium==3.5.0
requests==2.18.4
clint==0.5.1

0 comments on commit d4ba06e

Please sign in to comment.