获取网贷之家数据

 

获取这些数据

#coding=utf8
import requests
from datetime import date,timedelta
url = 'http://shuju.wdzj.com/plat-data-custom.html'

def get_date(days):
    return date.today() - timedelta(days=days)

def get_wdzj_data(timex):
    '''传入整形n天前或时间段'''
    if isinstance(timex,int):
        shujuDate = str(get_date(timex)) + str(get_date(1))
    else:
        shujuDate = timex

    print u'要获取的日期范围是:', shujuDate
    data = {'type':      '1',
        'shujuDate': shujuDate,
            }
    resp = requests.post(url,data = data)
    return  resp.content

if __name__ == '__main__':
    print get_wdzj_data(1)
    print get_wdzj_data(7)
    print get_wdzj_data(30)

    print get_wdzj_data('2017-09-012017-09-30')
    print get_wdzj_data('2017-08-012017-08-31')

 

posted @ 2017-10-24 15:43  北风之神0509  阅读(261)  评论(1编辑  收藏  举报