DataCollector.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # -*- coding: utf-8 -*-
  2. """
  3. @author: zsc
  4. @time: 2024/11/18
  5. @desc: 数据采集
  6. """
  7. import random
  8. # 数据收集模块
  9. class DataCollector:
  10. def __init__(self):
  11. self.data = []
  12. def collect(self):
  13. # 定义三个流程及其名称
  14. processes = {
  15. '申请流程': ['浏览-产品介绍页', '点击-立即申请', '浏览-公积金授权页', '浏览-额度申请结果'],
  16. '提额流程': ['点击-立即提额', '浏览-提额方式选择页', '点击-线上公积金认证', '浏览-提额申请结果'],
  17. '支用流程': ['点击-立即支用', '填写-借款申请页', '浏览-确认借款页', '浏览-支用结果页', '结果-支用成功']
  18. }
  19. users = ['User{}'.format(i) for i in range(1, 201)]
  20. for user in users:
  21. # 随机选择一个流程
  22. process_name, process_steps = random.choice(list(processes.items()))
  23. # 确保生成一个完整的行为序列
  24. start_index = 0
  25. end_index = random.randint(start_index, len(process_steps) - 1)
  26. actions = process_steps[start_index:end_index + 1]
  27. user_actions = {
  28. 'user': user,
  29. 'process': process_name,
  30. 'actions': actions,
  31. 'product': random.choice(['渝快贷', '渝悦贷', '房快贷']),
  32. 'channel': random.choice(['手机银行', '微银行'])
  33. }
  34. self.data.append(user_actions)
  35. return self.data