Skip to content

Commit

Permalink
更新csv下载规则
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Feb 11, 2018
1 parent b16c552 commit 9a96f20
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mazhifu/spider.py
@@ -1,14 +1,14 @@
import os
import time
from datetime import datetime
from datetime import datetime, timedelta

import requests
from lazyspider.lazystore import LazyMysql
from selenium import webdriver

from config import TEST_DB, USERNMAE, PASSWD
# 在当前目录运创建data目录
CSV_DIR = os.path.dirname(__file__) + '/csvdata/'
CSV_DIR = os.path.abspath(os.curdir) + '/csvdata/'
if not os.path.isdir(CSV_DIR):
os.mkdir(CSV_DIR)

Expand Down Expand Up @@ -150,12 +150,12 @@ def main():
# 模拟登录获取cookies:
pay = Mazhifu(HEADERS, USERNMAE, PASSWD)
COOKIES = pay.get_cookies()
# 今日日期
today = datetime.today().strftime('%Y-%m-%d')
# 昨天日期
yesterday = (datetime.today()-timedelta(days=1)) .strftime('%Y-%m-%d')
# 下载今日的账单文件
download_csv_by_date(today, COOKIES, HEADERS)
download_csv_by_date(yesterday, COOKIES, HEADERS)
# 处理csv文件并入库
items = deal_csv_file(CSV_DIR+today + '.csv')
items = deal_csv_file(CSV_DIR+yesterday + '.csv')
# 建立数据库链接
store = LazyMysql(TEST_DB)
for item in items:
Expand Down

0 comments on commit 9a96f20

Please sign in to comment.