├── LICENSE ├── MANIFEST ├── README.md ├── compareMe ├── __init__.py ├── bin │ └── compareMe ├── codechef.py ├── spoj.py └── spoj.pyc ├── dist ├── compareMe-0.1.tar.gz ├── compareMe-0.3.tar.gz ├── compareMe-0.4.tar.gz └── compareMe-0.5.tar.gz ├── setup.cfg └── setup.py /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Punit Dhoot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | # file GENERATED by distutils, do NOT edit 2 | setup.cfg 3 | setup.py 4 | compareMe/__init__.py 5 | compareMe/bin/compareMe 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #Compare Me 2 | >A command line app to compare users on different platforms. 3 | 4 | ##Installation 5 | 6 | `pip install compareMe ` 7 | 8 | ##Usage 9 | 10 | `compareMe -- user1 user2` 11 | 12 | 13 | 14 | Initially, I have just started with SPOJ but will increase the number of platforms with time. 15 | 16 | ##Screenshots 17 | ![Usage](http://i.imgur.com/EsBKWDK.png) 18 | 19 | ##License 20 | 21 | MIT © [Punit Dhoot](https://github.com/pdhoot) 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /compareMe/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdhoot/Compare-Me/8f8b4fbebffe032fa5e01f375cd128d226c82a85/compareMe/__init__.py -------------------------------------------------------------------------------- /compareMe/bin/compareMe: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | import argparse 3 | import sys, os 4 | sys.path.append('/usr/local/lib/python2.7/dist-packages/compareMe') 5 | import spoj 6 | import codechef 7 | 8 | 9 | parser = argparse.ArgumentParser(description='Compare users across different platforms') 10 | parser.add_argument('user1') 11 | parser.add_argument('user2') 12 | parser.add_argument('--spoj' , action='store_true') 13 | parser.add_argument('--codechef' , action='store_true') 14 | args = parser.parse_args() 15 | if args.spoj is True: 16 | spoj.main(args.user1 , args.user2) 17 | elif args.codechef is True: 18 | codechef.main(args.user1 , args.user2) 19 | else: 20 | parser.print_help() 21 | 22 | -------------------------------------------------------------------------------- /compareMe/codechef.py: -------------------------------------------------------------------------------- 1 | import urllib 2 | import threading 3 | from bs4 import BeautifulSoup 4 | 5 | def ScrapeUserData(username): 6 | url = 'http://www.codechef.com/users/' + username 7 | html = urllib.urlopen(url) 8 | soup = BeautifulSoup(html) 9 | table1 = soup.find('table' , {'class':'rating-table'}) 10 | td = table1.find_all('td') 11 | string = """ 12 | Rank Rating 13 | Long %s %s 14 | Short %s %s 15 | LTime(All) %s %s 16 | 17 | """ % (td[4].text , td[5].contents[0] , td[7].text , td[8].contents[0] , td[10].text , td[11].contents[0]) 18 | 19 | name = soup.find('div' , {'class':'user-name-box'}) 20 | print 21 | print ' '*7 , name.text 22 | print string 23 | 24 | def main(user1, user2): 25 | t1 = threading.Thread(target=ScrapeUserData , args=(user1,)) 26 | t2 = threading.Thread(target=ScrapeUserData , args=(user2,)) 27 | t1.start() 28 | t2.start() 29 | 30 | -------------------------------------------------------------------------------- /compareMe/spoj.py: -------------------------------------------------------------------------------- 1 | import urllib 2 | import threading 3 | from bs4 import BeautifulSoup 4 | 5 | def scrapUserData(username): 6 | url = 'http://www.spoj.com/users/' + username 7 | html = urllib.urlopen(url) 8 | soup = BeautifulSoup(html) 9 | div1 = soup.find('div' , {'class':'col-md-3'}) 10 | paragraphs = div1.find_all('p') 11 | user = div1.find('h4') 12 | data = user.text + '\n' 13 | dl = soup.find('dl' , {'class':'dl-horizontal profile-info-data profile-info-data-stats'}) 14 | dd = dl.find_all('dd') 15 | data=data + paragraphs[2].text + '\n' 16 | data = data + 'Prbolems Solved : ' + dd[0].text + '\n' 17 | data = data + 'Solutions Submitted : ' + dd[1].text + '\n' 18 | print data 19 | 20 | def main(user1 , user2): 21 | t1 = threading.Thread(target=scrapUserData , args=(user1,)) 22 | t2 = threading.Thread(target=scrapUserData , args=(user2,)) 23 | t1.start() 24 | t2.start() 25 | -------------------------------------------------------------------------------- /compareMe/spoj.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdhoot/Compare-Me/8f8b4fbebffe032fa5e01f375cd128d226c82a85/compareMe/spoj.pyc -------------------------------------------------------------------------------- /dist/compareMe-0.1.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdhoot/Compare-Me/8f8b4fbebffe032fa5e01f375cd128d226c82a85/dist/compareMe-0.1.tar.gz -------------------------------------------------------------------------------- /dist/compareMe-0.3.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdhoot/Compare-Me/8f8b4fbebffe032fa5e01f375cd128d226c82a85/dist/compareMe-0.3.tar.gz -------------------------------------------------------------------------------- /dist/compareMe-0.4.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdhoot/Compare-Me/8f8b4fbebffe032fa5e01f375cd128d226c82a85/dist/compareMe-0.4.tar.gz -------------------------------------------------------------------------------- /dist/compareMe-0.5.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pdhoot/Compare-Me/8f8b4fbebffe032fa5e01f375cd128d226c82a85/dist/compareMe-0.5.tar.gz -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [metadata] 2 | description-file = README.md -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from distutils.core import setup 2 | setup( 3 | name = 'compareMe', 4 | packages = ['compareMe' , 'compareMe.bin'], 5 | version = '1.0', 6 | description = 'A comparison library', 7 | author = 'Punit Dhoot', 8 | author_email = 'punitdhoot1@gmail.com', 9 | url = 'https://github.com/pdhoot/Compare-Me', 10 | download_url = 'https://github.com/pdhoot/Compare-Me/tarball/1.0', 11 | keywords = ['compare' , 'users' , 'spoj' ,'codechef' , 'github'], # arbitrary keywords 12 | classifiers = [], 13 | scripts = ['compareMe/bin/compareMe'], 14 | install_requires = ['beautifulsoup4'], 15 | license = 'MIT' 16 | ) 17 | --------------------------------------------------------------------------------