Create grab.js
This commit is contained in:
		
							parent
							
								
									c944fe3c61
								
							
						
					
					
						commit
						c4f48cab53
					
				
					 4 changed files with 1008 additions and 25 deletions
				
			
		|  | @ -1,2 +1,6 @@ | ||||||
| # schoolsoft-schema-parser | # schoolsoft-schema-parser | ||||||
| Parses schoolsoft schedules from 'right_student_schedule.jsp' file into readable json | Parses schoolsoft schedules from 'right_student_schedule.jsp' file into readable json | ||||||
|  | 
 | ||||||
|  | CURRENTLY REWRITING ENTIRELY, DONT LOOK AT IT :) | ||||||
|  | 
 | ||||||
|  | document.createElement('script').src = 'http://example.com/file.js'; | ||||||
							
								
								
									
										0
									
								
								grab.js
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								grab.js
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										990
									
								
								output.json
									
										
									
									
									
								
							
							
						
						
									
										990
									
								
								output.json
									
										
									
									
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
							
								
								
									
										37
									
								
								parser.py
									
										
									
									
									
								
							
							
						
						
									
										37
									
								
								parser.py
									
										
									
									
									
								
							|  | @ -1,27 +1,18 @@ | ||||||
| import sys | import sys | ||||||
| import json | import json | ||||||
| 
 | 
 | ||||||
| inputFile = '' |  | ||||||
| outputFile = '' |  | ||||||
| 
 |  | ||||||
| outputContent = {} |  | ||||||
| 
 |  | ||||||
| # Super janky script to parse right_student_schedule.jsp and save as readable json | # Super janky script to parse right_student_schedule.jsp and save as readable json | ||||||
| 
 | 
 | ||||||
| def getInput(): |  | ||||||
| 
 |  | ||||||
|     global inputFile, outputFile |  | ||||||
| 
 |  | ||||||
|     inputFile = input("Input file: ") |  | ||||||
|     outputFile = input("Output file: ") |  | ||||||
| 
 |  | ||||||
| def main(): | def main(): | ||||||
| 
 | 
 | ||||||
|     global inputFile, outputFile |     outputContent = {} | ||||||
| 
 | 
 | ||||||
|     # Set input and output file if not specified |     try: | ||||||
|     if inputFile == '': inputFile = 'right_student_schedule.jsp' |         inputFile = sys.argv[0] | ||||||
|     if outputFile == '': outputFile = 'output.json' |         outputFile = sys.argv[1] | ||||||
|  |     except: | ||||||
|  |         inputFile = 'right_student_schedule.jsp' | ||||||
|  |         outputFile = 'output.json' | ||||||
|      |      | ||||||
|     with open(inputFile,'r') as f: |     with open(inputFile,'r') as f: | ||||||
| 
 | 
 | ||||||
|  | @ -59,6 +50,8 @@ def main(): | ||||||
|                 else: # If not a range, just add the week |                 else: # If not a range, just add the week | ||||||
|                     weeks.append(int(y)) |                     weeks.append(int(y)) | ||||||
|              |              | ||||||
|  |             weeks.sort() | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|             # Extract lesson ID |             # Extract lesson ID | ||||||
|             lesson_id = 0 |             lesson_id = 0 | ||||||
|  | @ -97,10 +90,13 @@ def main(): | ||||||
| 
 | 
 | ||||||
|             room = x[sectionStartIndex:sectionEndIndex].strip('\n') |             room = x[sectionStartIndex:sectionEndIndex].strip('\n') | ||||||
| 
 | 
 | ||||||
|  |             if name == 'Lunch': room = '' # Prevent weird extraction of non-existent lunch room | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|             # Add all extracted values to entry |             # Add all extracted values to entry | ||||||
|             entry['name'] = name |             entry['name'] = name | ||||||
|             entry['room'] = room |             entry['room'] = room | ||||||
|  |             entry['day'] = "" # No idea how to do this | ||||||
|             entry['starts'] = classStart |             entry['starts'] = classStart | ||||||
|             entry['ends'] = classEnd |             entry['ends'] = classEnd | ||||||
|             entry['weeks'] = weeks |             entry['weeks'] = weeks | ||||||
|  | @ -110,16 +106,11 @@ def main(): | ||||||
|         f.close() |         f.close() | ||||||
| 
 | 
 | ||||||
|     with open(outputFile, 'w') as file: |     with open(outputFile, 'w') as file: | ||||||
|         json.dump(outputContent, file) |         json.dump(outputContent, file, indent=4) | ||||||
|      |      | ||||||
| 
 | 
 | ||||||
|          |          | ||||||
|              |              | ||||||
| 
 | 
 | ||||||
| if __name__ == '__main__': | if __name__ == '__main__': | ||||||
|     getInput() |     main() | ||||||
| else: |  | ||||||
|     inputFile = sys.argv[0] |  | ||||||
|     outputFile = sys.argv[1] |  | ||||||
| 
 |  | ||||||
| main() |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 MarcoVitchiThulin
						MarcoVitchiThulin