diff --git a/README.md b/README.md index 6fa065b..950451e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This is a commandline tool to find the online presence of a username in popular Install this tool via following command ~~~ -pip install netizenship +sudo pip3 install netizenship ~~~ ## Usage diff --git a/dist/netizenship-0.1.7-py3-none-any.whl b/dist/netizenship-0.1.7-py3-none-any.whl new file mode 100644 index 0000000..c32027b Binary files /dev/null and b/dist/netizenship-0.1.7-py3-none-any.whl differ diff --git a/dist/netizenship-0.1.7.tar.gz b/dist/netizenship-0.1.7.tar.gz new file mode 100644 index 0000000..b0abb40 Binary files /dev/null and b/dist/netizenship-0.1.7.tar.gz differ diff --git a/netizenship.py b/netizenship.py index 8d4e2e4..41924e0 100644 --- a/netizenship.py +++ b/netizenship.py @@ -17,70 +17,37 @@ import concurrent.futures from pyfiglet import figlet_format - -global websites -websites = { - 'Facebook': 'https://www.facebook.com/', - 'Twitter': 'https://twitter.com/', - 'Instagram': 'https://www.instagram.com/', - 'Youtube': 'https://www.youtube.com/user/', - 'Reddit': 'https://www.reddit.com/user/', - 'PInterest': 'https://www.pinterest.com/', - 'Flickr': 'https://www.flickr.com/people/', - 'Vimeo': 'https://vimeo.com/', - 'Soundcloud': 'https://soundcloud.com/', - 'Disqus': 'https://disqus.com/', - 'Medium': 'https://medium.com/', - 'AboutMe': 'https://about.me/', - 'Imgur': 'https://imgur.com/user/', - 'Flipboard': 'https://flipboard.com/', - 'Slideshare': 'https://slideshare.net/', - 'Spotify': 'https://open.spotify.com/user/', - 'Scribd': 'https://www.scribd.com/', - 'Patreon': 'https://www.patreon.com/', - 'BitBucket': 'https://bitbucket.org/', - 'GitLab': 'https://gitlab.com/', - 'Github': 'https://www.github.com/', - 'GoodReads': 'https://www.goodreads.com/', - 'Instructable': 'https://www.instructables.com/member/', - 'CodeAcademy': 'https://www.codecademy.com/', - 'Gravatar': 'https://en.gravatar.com/', - 'Pastebin': 'https://pastebin.com/u/', - 'FourSquare': 'https://foursquare.com/', - 'TripAdvisor': 'https://tripadvisor.com/members/', - 'Wikipedia': 'https://www.wikipedia.org/wiki/User:', - 'HackerNews': 'https://news.ycombinator.com/user?id=', - 'CodeMentor': 'https://www.codementor.io/', - 'Trip': 'https://www.trip.skyscanner.com/user/', - 'Blogger': '.blogspot.com', - 'Wordpress': '.wordpress.com', - 'Tumbler': '.tumblr.com', - 'Deviantart': '.deviantart.com"', - 'LiveJournel': '.livejournal.com', - 'Slack': '.slack.com', - -} - - def main(): - def banner(text, ch='=', length=78): spaced_text = ' %s ' % text banner = spaced_text.center(length, ch) print(banner) + + ascii_banner = figlet_format('Netizenship') + print(ascii_banner) + banner_text = "MIT License, Copyright (c) 2020 Rahul Raj" + banner(banner_text) + + status_code_html = 'https://en.wikipedia.org/wiki/List_of_HTTP_status_codes' + uname = input("Enter username: ") + width = 15 # to pretty print + global counter + counter = 0 # to count no of success + page = requests.get(status_code_html) + soup = BeautifulSoup(page.content, 'html.parser') + + def get_website_membership(site): - global uname - global websites url = websites[site] + global counter if not url[:1]=='h': link = 'https://'+uname+url else: link = url+uname state = "FAIL" - + msg = '--exceptin--' try: - # with eventlet.Timeout(20): response = requests.get(link) tag = soup.find(id=response.status_code) msg = tag.find_parent('dt').text @@ -91,27 +58,72 @@ def get_website_membership(site): else: state = 'SUCCESS' + counter += 1 print(site.rjust(width), ':', colored(state.ljust(width//2), 'green'), '(Status:', msg, ')') - ascii_banner = figlet_format('Netizenship') - print(ascii_banner) - banner_text = "MIT License, Copyright (c) 2020 Rahul Raj" - banner(banner_text) + websites = { + 'Facebook': 'https://www.facebook.com/', + 'Twitter': 'https://twitter.com/', + 'Instagram': 'https://www.instagram.com/', + 'Youtube': 'https://www.youtube.com/user/', + 'Reddit': 'https://www.reddit.com/user/', + 'PInterest': 'https://www.pinterest.com/', + 'Flickr': 'https://www.flickr.com/people/', + 'Vimeo': 'https://vimeo.com/', + 'Soundcloud': 'https://soundcloud.com/', + 'Disqus': 'https://disqus.com/', + 'Medium': 'https://medium.com/', + 'AboutMe': 'https://about.me/', + 'Imgur': 'https://imgur.com/user/', + 'Flipboard': 'https://flipboard.com/', + 'Slideshare': 'https://slideshare.net/', + 'Spotify': 'https://open.spotify.com/user/', + 'Scribd': 'https://www.scribd.com/', + 'Patreon': 'https://www.patreon.com/', + 'BitBucket': 'https://bitbucket.org/', + 'GitLab': 'https://gitlab.com/', + 'Github': 'https://www.github.com/', + 'GoodReads': 'https://www.goodreads.com/', + 'Instructable': 'https://www.instructables.com/member/', + 'CodeAcademy': 'https://www.codecademy.com/', + 'Gravatar': 'https://en.gravatar.com/', + 'Pastebin': 'https://pastebin.com/u/', + 'FourSquare': 'https://foursquare.com/', + 'TripAdvisor': 'https://tripadvisor.com/members/', + 'Wikipedia': 'https://www.wikipedia.org/wiki/User:', + 'HackerNews': 'https://news.ycombinator.com/user?id=', + 'CodeMentor': 'https://www.codementor.io/', + 'Trip': 'https://www.trip.skyscanner.com/user/', + 'Blogger': '.blogspot.com', + 'Wordpress': '.wordpress.com', + 'Tumbler': '.tumblr.com', + 'Deviantart': '.deviantart.com"', + 'LiveJournel': '.livejournal.com', + 'Slack': '.slack.com', + + } + + + +#------------------------------------------------------------------------ + # Following multithreading way goes to kind of deadlock sometime. + # Help-required to debug. As of now a for loop runs, (slowly) + + # with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: + # try: + # executor.map(get_website_membership, list(websites.keys()), timeout=5) + # except: + # print('Exception occured, skipping') + # pass + + for site in list(websites.keys()): + get_website_membership(site) + n_websites = len(list(websites.keys())) + print('Summary: User {} has membership in {}/{} websites'.format(uname, counter, n_websites)) + banner('completed') + +#------------------------------------------------------------------------- - status_code_html = 'https://en.wikipedia.org/wiki/List_of_HTTP_status_codes' - global uname - uname = input("Enter the username: ") - width = 15 - - page = requests.get(status_code_html) - soup = BeautifulSoup(page.content, 'html.parser') - - with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor: - try: - executor.map(get_website_membership, list(websites.keys()), timeout=5) - except: - print('Exception occured, skipping') - pass if __name__ == '__main__': main() \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index bd409a5..d1d5ab1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "netizenship" -version = "0.1.6" +version = "0.1.7" description = "Tool to check the username with popular websites for membership" authors = ["Rahul Raj "]