Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
fund_code
  • Loading branch information
1nchaos committed Aug 1, 2023
1 parent 3c86acb commit 7c4e49c
Show file tree
Hide file tree
Showing 8 changed files with 463 additions and 24 deletions.
2 changes: 1 addition & 1 deletion adata/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-

VERSION = (0, 0, 28)
VERSION = (0, 0, 29)
# PRERELEASE = None # alpha, beta or rc
PRERELEASE = 'beta' # alpha, beta or rc
REVISION = None
Expand Down
36 changes: 36 additions & 0 deletions adata/common/base/base_ths.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
"""
import copy
import datetime
import re
import time

from bs4 import BeautifulSoup
from py_mini_racer import py_mini_racer

from adata.common import requests
from adata.common.headers import ths_headers
from adata.common.utils.cookie import get_file_content_ths


class BaseThs(object):
Expand Down Expand Up @@ -55,3 +60,34 @@ def _get_years_by_start_date(self, start_date):
if current_year not in years:
years.append(current_year)
return years

def get_wencai_server_time(self):
"""
获取问财服务时间
:return: time
"""
url = 'http://www.iwencai.com/unifiedwap/home/index'
resp = requests.request(method='get', url=url)
resp_text = resp.text
soup = BeautifulSoup(resp_text, 'html.parser')
js_url = "http:" + soup.find('script')['src']
js_resp = requests.request(method='get', url=js_url)
js_text = js_resp.text
obj = re.compile(r'var TOKEN_SERVER_TIME=(?P<time>.*?);!function')
server_time = obj.search(js_text).group('time')
return server_time

def wencai_hexin_v(self, js_path="hexin.js"):
"""
wencai_hexin
"""
js_code = py_mini_racer.MiniRacer()
js_content = get_file_content_ths(file_path=js_path)
js_content = 'var TOKEN_SERVER_TIME=' + str(self.get_wencai_server_time()) + ";\n" + js_content
js_code.eval(js_content)
v = js_code.call("rt.updata")
return v


if __name__ == '__main__':
print(BaseThs().wencai_hexin_v())
2 changes: 1 addition & 1 deletion adata/common/exception/exception_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

THS_IP_LIMIT_RES = '<h1>Nginx forbidden.</h1>'
"""同花顺Ip限制的返回结果"""
THS_IP_LIMIT_MSG = "ths流量防控:当前ip被限制,请降低请求频率或更换ip或使用代理设置!!!"
THS_IP_LIMIT_MSG = "ths流量防控:当前ip被限制,请降低请求频率或更换ip或使用代理设置,勿使用国外ip!!!"
"""同花顺IP:403限制提醒"""
Loading

0 comments on commit 7c4e49c

Please sign in to comment.