Last active
May 23, 2017 08:44
-
-
Save ramsane/ee55c7e9e9b388abe6773dca0b9c996e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Note: you must have following dependencies to run this program | |
If you have pip installed, you can easily install some libraries | |
like beautifulsoup4, lxml which are required for this program. | |
sudo pip install beautifulsoup4 | |
sudo pip install lxml | |
lxml is a parser and beautiful soup uses that parser to parse webpages. | |
If you are on windows, sudo is not necessry.. :) :) :) | |
''' | |
import bs4 as bs # it is beautifulsoup4.. | |
from urllib2 import urlopen | |
import random | |
import sys | |
# "from urllib import request" for python3 | |
# use "request.urlopen()" for python3 | |
try: | |
source = urlopen("http://www.ravindrababuravula.com/focus.php#slist").read() | |
except Exception as e: | |
print e | |
print 'You better check with the url of page...' | |
print 'OR there might not be any internet connection in your device' | |
sys.exit() | |
soup = bs.BeautifulSoup(source, 'lxml') | |
print 'getting the names from website....' | |
names = [] | |
# encoding reduces the size almost to 60% than unicode string | |
for div in soup.find_all('div', class_='panel-group'): | |
names.extend([name.string.strip().encode('utf-8', 'ignore') | |
for name in div.find_all('td') if name.string is not None]) | |
print "we got them.." | |
# print type(names[5]) | |
# print sys.getsizeof(names[1]) | |
def print_group(group, group_no): | |
print'Group : {}'.format(group_no) | |
for name in group: | |
print " {}".format(name) | |
# for some space before another group | |
print '' | |
# you can change the default size if you want to | |
def print_all_groups(names, group_size=5): | |
group_no = 0 | |
while(len(names) > 0): | |
group_no += 1 | |
group = names[:group_size] | |
print_group(group, group_no) | |
del names[:5] | |
random.shuffle(names) | |
def print_all_groups_with_caution(names, group_size=5): | |
group_no = 0 | |
while(len(names) > 0): | |
group_no += 1 | |
group, girl_is_added = [], False | |
while len(group) < group_size: | |
name = names[-1] | |
if girls and is_girl(name): # girls is a global list of girl names.. | |
if girl_is_added: # we cannot add another one. May be next time.. | |
names[0], names[-1] = names[-1], names[0] | |
continue | |
else: | |
group.append(names.pop()) # removes last element ie.,at index -1 | |
girls.remove(name) | |
else: | |
group.append(names.pop()) | |
print_group(group, group_no) | |
random.shuffle(names) | |
def is_girl(name): | |
return True if name in girls else False | |
print 'shuffling names....' | |
random.shuffle(names) | |
print 'done' | |
scatter = False | |
print "Do you want to divide in such a way that, No 2 girls in the same group.." | |
print "Because there are less than 60 girls in focus batch..." | |
repl = raw_input("yes/no: ") | |
if repl != 'no': | |
scatter = True | |
girls = [] | |
if scatter: | |
# get names of girls into girls list.. | |
with open('focus_girls') as gl: | |
for line in gl: | |
girls.append(line.strip()) | |
print "here you go....\n\n" | |
print_all_groups_with_caution(names) | |
else: | |
print_all_groups(names) | |
# print girls | |
# print is_girl('Khyati Verma') | |
print '1: You must need an internet connection..' | |
print '2: You can change the group capacity if you want to, in the program.' | |
print "3: type ''python groupings.py > file_name'' to redirect the output to a file..", | |
print "and check your batchmates.. :)", | |
print "while doing so, don't forget to type yes/no. Because this program requires it for....." | |
print "You already know it. Don't you..?" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Aishwarya Desai | |
Amisha Priyadarshini | |
Anisha Paul | |
Anjali Sharma | |
Anmol Maheshwari | |
Astha Tembhre | |
Bhagyalakshmi Pasula | |
Bhavana Pajjuri | |
Bhuvaneswari.P | |
Dharani jayakanthan | |
Disha Sharma | |
Divya Bansal | |
Grishma Shaw | |
Heena Bhansali | |
Katyani Jaiswal | |
Keerthana | |
Keerthi S | |
Khyati Verma | |
Kritika Sharma | |
Manaswita Datta | |
Meghana Gotlur | |
Motamarri Anusha | |
Mrunalini Pilli | |
Neetu Yadav | |
Neha Singh | |
Nishitha Kapuluru | |
Ooha Kosanam | |
P.K.Sameera | |
Payal Dey | |
Piyali Dutta | |
Pooja Gupta | |
Pratima Purohit | |
Priya Shankar | |
Pushpanjali Prasad | |
Rashi Adukia | |
Rashmi M | |
Saru Brar | |
Sayantani Ghosh | |
Shalini Verma | |
Shweta Singh | |
Sukannya Purkayastha | |
Surabhi Shrivastav | |
Surbhi Gupta | |
Vasanthi | |
Vishnu Priya Marripati |
Since the layout in focus page changed in ravindrababuravula.com.., this program is changed accordingly. Now It will get all 300 students and group them into 5 members each
P S: As some names are removed from focus batch (from first list of candidates..), this program will exclude them as well
It's probably final update.. I think..
Make sure you download the names file too...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is small program, to team up the students who are selected for Focus Batch - 2018 as 5 members each ( Of Course, you can change it in code... ).
It has only 170 students. It works for those 170 students as of now
It is just for fun. You can do whatever you want with it. I don't care..