Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit f589296

Browse files
committed
期货信息爬虫
1 parent 08c1b78 commit f589296

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-12
lines changed

qq加群/qihuo_spider.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# @Time : 2020/4/15 18:29
2+
# @Author : Libuda
3+
# @FileName: qihuo_spider.py
4+
# @Software: PyCharm
5+
6+
import requests
7+
8+
9+
def spider():
10+
url = "https://flash-api.jin10.com/get_flash_list?channel=2"
11+
headers = {
12+
'accept': '*/*',
13+
'accept-encoding': 'gzip, deflate, br',
14+
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
15+
# 'cookie': 'UM_distinctid=1717d593c7d74c-0998a4179c093a-5313f6f-144000-1717d593c7e5bc; x-token=',
16+
'origin': 'https://www.jin10.com',
17+
'referer': 'https://www.jin10.com/',
18+
'sec-fetch-dest': 'empty',
19+
'sec-fetch-mode': 'cors',
20+
'sec-fetch-site': 'same-site',
21+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36',
22+
'x-app-id': 'SO1EJGmNgCtmpcPF',
23+
'x-version': '1.0.0',
24+
}
25+
response = requests.get(url, headers=headers).json()
26+
27+
res = []
28+
for i in range(10):
29+
tem = response['data'][i]['data']['content']
30+
if "现货报价" in tem or "了解请戳" in tem:
31+
continue
32+
tem = tem.replace("金十期货讯", "").replace("。", "。/n/n").replace("<b>", "")
33+
res.append(tem)
34+
35+
return 0, res
36+
37+
38+
if __name__ == '__main__':
39+
res = spider()
40+
print(res)

qq加群/tt.py renamed to qq加群/企业微信发消息.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @Time : 2020/4/4 17:13
22
# @Author : Libuda
3-
# @FileName: tt.py
3+
# @FileName: 企业微信发消息.py
44
# @Software: PyCharm
55
import win32gui
66
import win32api
@@ -11,6 +11,7 @@
1111
import ctypes
1212
import pyautogui
1313

14+
from qq加群.qihuo_spider import spider as qihuo_spider
1415
from qq加群.spider import spider
1516

1617
# 安全限制
@@ -20,7 +21,7 @@
2021
# qq_or_wx = "ChatWnd" #微信
2122
qq_or_wx = "WwStandaloneConversationWnd" # 企业微信
2223
sleep_time = 300
23-
24+
send_message_count = 10 # 每隔多长时间发送一次联系人微信
2425
# 休眠时间
2526
winname = ["阿尔萨斯"] # 需要发送的
2627

@@ -29,7 +30,10 @@
2930
totol_dic = set() # 去重
3031

3132
l, res = spider()
32-
res = res
33+
q_l, q_res = qihuo_spider()
34+
35+
res = res + q_res
36+
3337
for one in res:
3438
totol_dic.add(one)
3539

@@ -137,22 +141,24 @@ def sendMsgToWX(msg, winname):
137141

138142

139143
def main(winname):
140-
# totol_dic = set()
141-
# 接收内容
142-
# l, res = spider()
143-
# res = res
144-
# for one in res:
145-
# totol_dic.add(one)
146-
144+
count =0
147145
global totol_dic
148146
while 1:
149147
logger("检测新闻中")
150148
try:
151-
new_l, new_res = spider()
149+
qihuo_l, qihuo_res = qihuo_spider()
150+
new_l, res = spider()
151+
152+
new_res = qihuo_res + res
153+
152154
if new_res:
153155
for one in new_res:
154156
if one not in totol_dic:
155-
tem = time.strftime("%H:%M", time.localtime(time.time())) + " " + one + add_txt
157+
count += 1
158+
if count % send_message_count == 0:
159+
tem = time.strftime("%H:%M", time.localtime(time.time())) + " " + one + add_txt
160+
else:
161+
tem = time.strftime("%H:%M", time.localtime(time.time())) + " " + one
156162
for wn in winname:
157163
if sendMsgToWX(tem, wn):
158164
logger("发送成功:{}".format(tem))

0 commit comments

Comments
 (0)