-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresume_manager.py
166 lines (115 loc) · 5.11 KB
/
resume_manager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
from bs4 import BeautifulSoup
import mechanize
from prettytable import PrettyTable
import csv
def getData(rollno, password):
absoluteUrl = "http://tnp.dtu.ac.in/rm_2016-17/login/"
br = mechanize.Browser()
br.set_handle_robots( False )
br.addheaders = [('User-agent', 'Firefox')]
br.open(absoluteUrl)
br.select_form(nr=0)
br.form['student_username_rollnumber'] = rollno
br.form['student_password'] = password
response = br.submit()
soup = BeautifulSoup(response,'html.parser')
ul = soup.find('ul',attrs={'class':'timeline'})
count = 0
absoluteUrl = "http://tnp.dtu.ac.in/rm_2016-17/login/index"
while count >= 0:
# print absoluteUrl
li_time_label = ul.find_all('li',attrs={'class':'time-label'})
if len(li_time_label) == 0:
break
div_timeline_item = ul.find_all('div',attrs={'class':'timeline-item'})
for i in range(len(li_time_label)):
print li_time_label[i].text.strip(' \t\n\r')
time = div_timeline_item[i].span.text.strip(' \t\n\r')
time = time.replace(" ","")
time = time.replace(";","")
timelineHeader = div_timeline_item[i].find('h4',attrs={'class':'timeline-header'})
# if timelineHeader:
timelineBody = div_timeline_item[i].find('div',attrs={'class':'timeline-body'})
timelineHeaderUp = div_timeline_item[i].find('h3',attrs={'class':'timeline-header up'})
print time
print timelineHeader.text.strip(' \t\n\r')
# print timelineBody.text,"\n"
p = timelineBody.find_all('p')
for j in range(len(p)):
print p[j].text
print "\n-------------------"
timelineHeader = ""
timelineBody = ""
print "-------End of Page ",count,"-------"
links = br.links()
if count == 0:
# print links
jobopenings = links[5]
# print jobopenings
# print links[len(links)-2]
m = links[len(links)-2].url.replace("http://tnp.dtu.ac.in/rm_2016-17/student/index/","")
m = int(m)
url = links[len(links)-3]
value = url.url.replace("http://tnp.dtu.ac.in/rm_2016-17/student/index/","")
if int(value) >= m:
url = links[len(links) - 2]
absoluteUrl = url.url
count += 50
response = br.follow_link(url)
soup = BeautifulSoup(response, 'html.parser')
ul = soup.find('ul', attrs={'class': 'timeline'})
# print jobopenings
response = br.open("http://tnp.dtu.ac.in/rm_2016-17/student/search_job_openings/")
soup = BeautifulSoup(response, 'html.parser')
# table_jobopenings = soup.find('table',attrs={'id':'jobs_search'})
table = PrettyTable(['Company Name', 'Branches', 'Application Deadline', 'B.Tech', 'M.Tech', 'MBA', 'DateofVisit'])
# links = br.links()
trs = soup.find_all('tr')
companyDetails = []
company = {}
count = 1
for i in range(1):
for tr in trs:
tds = tr.find_all('td')
if len(tds) == 0:
continue
else:
company = {}
linkForCompany = tr['onclick']
linkForCompany = linkForCompany.replace("void window.open(","")
linkForCompany = linkForCompany.replace(")","")
company = {'LinkForCompany':linkForCompany}
temp = []
for td in tds:
i = td.find_all('i')
if len(i) > 0:
degree = i[0]['class'][1]
temp.append(degree)
else:
# print td.text
temp.append(td.text)
company['Company Name'] = temp[0].replace(","," ")
company['Branches'] = temp[1].replace(","," ")
company['Application Deadline'] = temp[2]
company['B.Tech'] = temp[3]
company['M.Tech'] = temp[4]
company['MBA'] = temp[5]
company['DateofVisit'] = temp[6]
companyDetails.append(company)
if len(temp) == 7:
table.add_row(temp)
# print table
# print companyDetails
print "Companies ----------------------"
with open('../../companies_placement.csv', 'wb') as csv_file:
spamwriter = csv.writer(csv_file, delimiter=',',
quotechar='|', quoting=csv.QUOTE_MINIMAL)
spamwriter.writerow(['Company Name', 'Branches', 'Application Deadline', 'B.Tech', 'M.Tech', 'MBA', 'DateofVisit', 'Link'])
for company in companyDetails:
spamwriter.writerow([company['Company Name'].encode("utf-8"), company['Branches'].encode("utf-8"), company['Application Deadline'].encode("utf-8"), company['B.Tech'].encode("utf-8"), company['M.Tech'].encode("utf-8"), company['MBA'].encode("utf-8"), company['DateofVisit'].encode("utf-8"), company['LinkForCompany'].encode("utf-8")])
return companyDetails
# getData()
if __name__ == "__main__":
rollno = raw_input("Enter roll no:")
password = raw_input("Enter password:")
getData(rollno,password)