我正在尝试建立一个机器人,可以自动安排我学校的会议室。目前有一个网站处理这个问题,但它是非常乏味的。我得到了最小的curl命令,可以成功地进行这些预订。但是,当我切换到使用python请求时,会出现一个错误,好像我预订了太多的站点。但是,如果在之后运行相同的curl命令,则不会出现错误。我认为http请求有问题,但我不知道从哪里开始。
卷曲:
curl 'https://api3.libcal.com/process_roombookings.php?m=booking_mob&iid=1723' \
-XPOST \
-H 'Referer: https://api3.libcal.com/room_widget.php?gid=4066&iid=1723' \
--data 'gid=4066&sid%5B%5D=660065516&fname=<First Name>&lname=<Last Name>&email=<School Email>&q1=<Student ID>&q2=4-6&q3=Engineering&q4=CPE&qcount=4&fid=2166'
python请求:
url = 'https://api3.libcal.com/process_roombookings.php'
headers = {
'Referer': 'https://api3.libcal.com/room_widget.php?gid=4066&iid=1723',
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
'X-Requested-With': 'XMLHttpRequest'
}
params = (
('m', 'booking_mob'),
('iid', '1723'),
)
data = {
'gid': '4066',
'sid': ['660065216'],
'fname': '<First Name>',
'lname': '<Last Name>',
'email': '<Personal email>',
'q1': '<Student Id>',
'q2': '4-6',
'q3': 'Engineering',
'q4': 'CPE',
'qcount': '4',
'fid': '2166'
}
request = requests.request('POST', url, headers=headers, params=params, data=data)
卷曲输出:
{"status":2,"msg":"<div class=\"alert alert-warning\"><p><strong>This booking is tentative only!<\/strong><\/p><p><span class='rm_book_tent'>Room I, 12:00am - 1:00am Friday, February 15, 2019 - Tentative<\/span><br\/><\/p><p>You must confirm the booking within 1 hour, via the URL contained in the email just sent to you.<\/p><\/div>","type":""}
python请求输出:
{'status': 2, 'msg': '<div class="alert alert-danger"><p><strong>You have exceeded the booking limits/quota:</strong></p><p></p><p></p></div>', 'type': ''}
卷曲将与原始卷曲相同。所以我只有在使用请求时才会认为这是其他错误。
你知道为什么一个人在返回一个网站(状态=200)时出现了一个错误而不是进行预订吗?
附:我见过这个问题问过几次,但大多数似乎是一个认证问题。我的感觉完全不同。