forked from Chihihiro/CrawlerFrame
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path三秒贷.py
94 lines (61 loc) · 1.91 KB
/
三秒贷.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time : 2019年01月26日 11:08
# @Author : Joyce
# @Project : CrawlerFrame
# @File : 三秒贷.py
# @Software: PyCharm
# @Describe:
import json
from time import sleep
from Frame.Crawler import BaseSpider
from Frame.Request import Request
class Spider(BaseSpider, Request):
def __init__(self, account):
super(Spider, self).__init__(account)
def get_info(self):
# xpath信息
xpath_info = {
"username": '//*[@id="userName"]',
"password": '//*[@id="userPwd"]',
"login_button": '/html/body/div/div/div/label[4]/a',
"message_code": '',
"check_code": '',
"code_image": '',
"success_ele": '//*[@id="menu-user-face"]'
}
cookie = self.login(xpath_info) # 获取cookie
print(cookie)
# json的url地址
json_url = f"http://agent.3md.mzjgx.com/loan/agentPlatform/queryCPA?startTime={self.today}+00%3A00%3A00&endTime={self.tomorrow}+00%3A00%3A00&agentId=361&page=1&rows=25"
info = json.loads(
self.request(json_url, method="get", cookie_dict=cookie)
)["data"]
print(info)
# 最终结果
result = {
"注册人数": info["total"],
"实名人数": "null",
"申请人数": "null",
"放款人数": "null",
"备注": "",
"地区": self.area,
"产品要求": self.requirements
}
# print(result)
self.write_sql(result)
account_info = {
"login_url": "http://agent.3md.mzjgx.com/login.html",
"area": 1,
"product": "三秒贷",
"username": "3mf25",
"password": "112233",
"message_code": "",
"channel": "",
"requirements": "下款3%",
"remark": "",
}
while True:
product = Spider(account_info)
product.get_info()
sleep(600)