占座

一、2021年9月27日

每天的页面是get请求。今天先写一个生成URL的程序快人一步。

from dateutil import rrule
from datetime import datetime
import time
from datetime import date, timedelta


# 计算日期间隔
def cal_days(time_1, time_2):
    # 第一个日期
    initDate = datetime.strptime(time_1, '%Y-%m-%d')
    firstDay = datetime(initDate.year, initDate.month, initDate.day)

    # 第二个日期
    initDate = datetime.strptime(time_2, '%Y-%m-%d')
    endDay = datetime(initDate.year, initDate.month, initDate.day)

    # rrule.DAILY计算天差,此外还有  星期(WEEKLY),年(YEARLY)
    days = rrule.rrule(freq=rrule.DAILY, dtstart=firstDay, until=endDay)

    # print('相差:',days.count(),'天')
    return days.count()


after_tomorrow = (date.today() + timedelta(days=2)).strftime("%Y-%m-%d")  # 后天的时间
tomorrow = (date.today() + timedelta(days=1)).strftime("%Y-%m-%d") #明天

num_days = cal_days('2021-9-26', after_tomorrow)  # 相隔时间

# print(num_days)
CHU = 1326965
xian = CHU + num_days - 1
str1 = "https://lxl.sdyu.edu.cn/web/seat3?area=8&segment=" + str(xian) + "&day=" + str(after_tomorrow) + "&startTime=07:00&endTime=22:30"

print("今天抢座的网址是:")
ming = xian - 1
str2 = "https://lxl.sdyu.edu.cn/web/seat3?area=8&segment=" + str(ming) + "&day=" + str(tomorrow)+ "&startTime=07:00&endTime=22:30"
print(str2)
print()
print("前一天晚上用:","      ")
print("明天抢座的网址是", ":")
print("后天{}的座".format(after_tomorrow))
print(str1)

 

上一篇:Linux Shell中单引号、双引号、反引号的区别【转载】


下一篇:经验之用Unity做《80 Days》PC版游戏移植