1

我尝试这样的事情

import requests
from datetime import datetime
from apscheduler.scheduler import Scheduler



url = 'http://example.com?'
headers = {
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
}

data = {'simple'='good'}

def my_job():
    r = requests.post(url, data=data, headers=headers)
    print r.text
    print datetime.now()

if __name__ == '__main__':
    scheduler = Scheduler(standalone=True)

    job = scheduler.add_date_job(my_job, '2013-12-31 13:53:27.100000')
    print('Press Ctrl+C to exit')
    try:
        scheduler.start()
    except (KeyboardInterrupt, SystemExit):
        pass

我的问题是触发器触发,但 req 函数中的打印没有显示。似乎无法发送请求。请求功能是健康的,因为尝试了它,但它不适用于调度程序。

4

0 回答 0