Python Requests Library: Fetching Classroom Availability Data from NEPU
The code uses the Python 'requests' library to make an HTTP GET request to the URL 'http://jwcwx.nepu.edu.cn/free-class-room/classroomUsedData'. It constructs the URL by concatenating a string with the value of the 'coursetime' list at index 0. The request includes a cookie named 'JSESSIONID' with a specific value. The response from the server is in JSON format, which is then printed to the console.
Here's a breakdown of the code:
- 'import requests': Imports the 'requests' library for making HTTP requests.
- 'cookies = {'JSESSIONID': '979EB8A4FB45297AA14D52989E787062'}': Defines a dictionary containing the 'JSESSIONID' cookie value.
- 'coursetime = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']': Creates a list containing time slots, likely representing hours in a day.
- 'response = requests.get('http://jwcwx.nepu.edu.cn/free-class-room/classroomUsedData?jwCode=内容:140001&week=1&day=1&time=' + coursetime[0], cookies=cookies)': Makes an HTTP GET request to the specified URL. The URL includes the 'jwCode', 'week', 'day', and 'time' parameters. The 'time' parameter is set to the first element of the 'coursetime' list.
- 'print(response.json())': Prints the JSON response received from the server to the console.
原文地址: https://www.cveoy.top/t/topic/nenm 著作权归作者所有。请勿转载和采集!