其他分享
首页 > 其他分享> > 占座

占座

作者:互联网

一、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)

 

标签:-%,占座,initDate,days,datetime,print,tomorrow
来源: https://www.cnblogs.com/WG11/p/15341177.html