Example #1
0
	def message(self, message_id):
		html                           = urllib2.urlopen("%s/Messaging/MessageRead.aspx?id=%i" % (self.base_url, message_id)).read()
		message                        = {"attachments": [], "participants": [], "posts": []}
		message['owner']               = self.username
		message['body']                = cre.prettify(cre.all_between('<span id="ctl00_ContentPlaceHolder2_postRepeater_ctl.._textLabel">', '</span>', html)[-1])
		message['title']               = cre.prettify(cre.between('<span id="ctl00_ContentPlaceHolder2_topicLabel">', '</span>', html))
		message['created']             = cre.prettify(cre.between('<span id="ctl00_ContentPlaceHolder2_dateLabel">', '</span>', html))
		trash                          = cre.all_between('<span id="ctl00_ContentPlaceHolder2_postRepeater_ctl.._posterLabel">', '</p>', html)
		del trash[-1]
		for trash in trash:
			username                   = trash.split("</span>")[0]
			body                       = trash.split("</span>")[-2].split('_textLabel">')[-1]
			date                       = cre.between('<span id="ctl00_ContentPlaceHolder2_postRepeater_ctl.._Label1">', '</span>', trash)
			post = {"username": username, "date": date, "body": body}
			message['posts'].append(post)

		trash                          = cre.between('<a id="ctl00_ContentPlaceHolder2_creatorLink" href="/User.aspx\?id=', '</a></h3>', html).split('">')
		message['creator']             = {'user_id': int(trash[0]), "name": trash[1]}
		participants_dirty_html_chunks = cre.between('<h3>Deltagare: ', '</h3>', html).split(', ')
		for dirty_participant_chunk in participants_dirty_html_chunks:
			user_id                    = int(cre.between('<a href="/User.aspx\?id=', '">', dirty_participant_chunk))
			username                   = cre.between('">', '</a>', dirty_participant_chunk)
			participant                = {"user_id": user_id, "username": username}
			message['participants'].append(participant)
			for post_id in range(len(message['posts'])):
				if message['posts'][post_id]['username'] == username:
					message['posts'][post_id]['user_id'] = user_id
		
		dirty_attachment_html_chunks   = cre.all_between('_AttachmentLink" href="', '</a></li>', html)
		for chunk in dirty_attachment_html_chunks:
			attachment                 = {"url": chunk.split('"')[0], "filename": chunk.split('">')[-1]}
			message['attachments'].append(attachment)

		return message
Example #2
0
	def food_menu(self):
		menu             = {"monday": "", "tuesday": "", "wednesday": "", "thursday": "", "friday": ""}
		html             = urllib2.urlopen("https://www.vklass.se/MySchool.aspx").read()
		days             = cre.all_between('<strong><span id="ctl00_ContentPlaceHolder2_lunchRepeater_ctl.._dayLabel">', '</span></strong>', html)
		meals            = cre.all_between('<span id="ctl00_ContentPlaceHolder2_lunchRepeater_ctl.._dayMenuLabel">', '</span>', html.replace("<br />", "").replace("\n", "").replace("\r", ""))

		for id in range(len(days)):
			for day in [["M", "monday"], ["Ti", "tuesday"], ["Ons", "wednesday"], ["To", "thursday"], ["F", "friday"]]:
				if days[id].startswith(day[0]):
					menu[day[1]] = meals[id]

		return menu
Example #3
0
	def class_calendar_exam_ids(self):
		url  = "%s/ClassCalendar.aspx?id=%s" % (self.base_url, self.class_uid())
		html = urllib2.urlopen(url).read()
		client.dump(html)
		ids = [int(id) for id in cre.all_between('<a href="ExamStatistics\\.aspx\\?id=', '&', html)]

		return ids
Example #4
0
	def class_events(self):
		events       = []
		html         = urllib2.urlopen("%s/ClassCalendar.aspx?id=%s" % (self.base_url, self.class_uid())).read()
		event_chunks = cre.all_between('<span id="ctl00_ContentPlaceHolder2_monthsRepeater_ctl.._eventsRepeater_ctl.._topicLabel">Klassh..ndelse: ', '</span></dd>', html)
		for trash in event_chunks:
			event = {"name": trash.split("</span>")[0], "description": trash.split('">Beskrivning: ')[-1]}
			events.append(event)

		return events	
Example #5
0
	def status(self):
		# This one is called scoreboard on vklass.se. Ugly and hackish, fix later..
		html = urllib2.urlopen("%s/Handler/scoreboard.ashx" % self.base_url).read()
		info = []
		for trash in cre.all_between("</span>", "</dd><dt><a href=", html):
			info.append(trash.split(">")[-1])

		status = {'guestbook': info[0], 'messages': info[1], 'forum': info[2], 'friends': info[3]}

		return status
Example #6
0
	def news_listing(self):
		html     = urllib2.urlopen("%s/MySchool.aspx" % self.base_url).read()
		dirty_news_ids = cre.all_between('<a id="ctl00_ContentPlaceHolder2_newsRepeater_ctl', "&amp;", html)
		clean_news_ids = []
		for dirty_news_id in dirty_news_ids:
			clean_news_id = dirty_news_id.split("=")[2]
			if int(clean_news_id) not in clean_news_ids:
				clean_news_ids.append(int(clean_news_id))
	
		return clean_news_ids
Example #7
0
	def domains(self):
		html    = urllib2.urlopen("https://customerzone.loopia.se/domains/properties/index/domain/").read()
		options = cre.all_between("<option", '</option>', html)
		domains = []
		for option in options:
			label = cre.between('label="', '"', option)
			name  = option.split(">")[-1]
			id    = cre.between('value="', '"', option)
			if name == label and "." in name:
				domains.append({'id': id, 'name': name})
		return domains
Example #8
0
	def latest_profile_visitors(self):
		visitors = []
		html     = urllib2.urlopen("%s/UserVisitors.aspx" % self.base_url).read()
		trash    = cre.all_between('<td class="logg-name">', '</span></td>', html)
		for trash in trash:
			visitor = {}
			visitor['name'] = trash.split('"')[3]
			if visitor['name'].endswith('_dateLabel'):
				visitor['name'] = "anonymous"
			visitor['time'] = trash.split(">")[-1]
			visitors.append(visitor)
		visitors.reverse()

		return visitors
Example #9
0
	def current_schedule(self):
		# Will show the current schedule for this week. Ugly and hackish, fix later..
		html     = urllib2.urlopen("%s/schema.aspx" % self.base_url).read()
		lessons  = {"monday": [], "tuesday": [], "wednesday": [], "thursday": [], "friday": []}
		for chunk in cre.all_between('<div class="LessonInfoContainer"', '</td>', html):
			name = chunk.split("<br />")[-3].split("<span>")[-1]
			room = chunk.replace("</span></div>", "").split(">")[-1]
			for thingie in room.split(" "):
				try:
					room = int(thingie)
				except:
					pass
			time             = cre.between('px;">', "<br />", chunk)
			day              = time.split(" ")[0]
			from_hour        = time.split(" ")[1]
			to_hour          = time.split(" ")[3]
			day_replacements = [["M", "monday"], ["Ti", "tuesday"], ["Ons", "wednesday"], ["To", "thursday"], ["F", "friday"]] 
			for replacement in day_replacements:
				if day.startswith(replacement[0]):
					day = replacement[1]
			lesson = {"name": name, "room": room, "from": from_hour, "to": to_hour}
			lessons[day].append(lesson)
		return lessons
Example #10
0
	def first_message_ids(self):
		return [int(x) for x in cre.all_between('href="MessageRead.aspx\?id=', '&amp;', urllib2.urlopen(self.base_url + "/Messaging/Messages.aspx").read())]
Example #11
0
	def courses(self):
		html    = urllib2.urlopen("%s/courselist.aspx" % self.base_url).read()
		courses = cre.all_between('<td class="kurs"><a id="ctl00_ContentPlaceHolder2_StudentRepeater_ctl.._courseLink" href="Course.aspx\?id=.{5}">', '</a>', html)
		
		return courses