Skip to content

Commit 7074c2f

Browse files
committed
修复腾讯云函数问题,增加输出
1 parent 2fcc3b1 commit 7074c2f

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

index_scf.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# -*- coding: utf8 -*-
2-
# 腾讯云SCF脚本,须在在线IDE终端,1- cd src , 2- pip install bs4 -t .
2+
# 腾讯云SCF脚本
33
import io
44
import random
55
import sys
@@ -9,6 +9,9 @@
99
from bs4 import BeautifulSoup
1010

1111
from user import user
12+
import logging
13+
logger = logging.getLogger()
14+
logger.setLevel(logging.INFO)
1215

1316
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf8') # 改变标准输出的默认编码
1417

@@ -37,6 +40,7 @@ def auto(user, url):
3740

3841
resp = request.urlopen(req)
3942
print("【", resp.getcode(), "】", "已访问:", url)
43+
logger.info("【{}】已访问:{}".format(resp.getcode(),url))
4044
u3 += "【" + str(resp.getcode()) + "】" + "已访问:" + url + "<br>"
4145
except Exception as e:
4246
u3 += e.__str__() + "<br>"
@@ -55,9 +59,10 @@ def getCredit(user, url):
5559

5660
resp = request.urlopen(req)
5761
bs = BeautifulSoup(resp.read().decode('utf-8'), "html.parser")
58-
em = bs.findAll('li')[100]
62+
em = bs.findAll('li')[99]
5963
uname = bs.find("h2", {'class': 'mbn'}).text
6064
print(em.text)
65+
logger.info(em.text)
6166
u3 += em.text + "<br>"
6267
except Exception as e:
6368
u3 += e.__str__() + "<br>"
@@ -71,6 +76,7 @@ def pushMsg(url):
7176
'Safari/537.36')
7277
resp = request.urlopen(req)
7378
print("推送消息结果:", str(resp.read(), 'utf-8'))
79+
logger.info("推送消息结果:{}".format(str(resp.read(), 'utf-8')))
7480

7581

7682
def autoCheck(user):
@@ -81,14 +87,17 @@ def autoCheck(user):
8187
print("其乐自动签到 By Moecola.com")
8288
print("--------------------------")
8389
print("【签到开始】")
90+
logger.info("【签到开始】")
8491
u3 += '【签到开始】 '
8592
getCredit(user, user.user_page)
8693
auto(user, u1)
8794
auto(user, u2)
8895
print("【签到结束】")
96+
logger.info("【签到结束】")
8997
u3 += '【签到结束】 '
9098
getCredit(user, user.user_page)
9199
print(uname, "签到完成")
100+
logger.info("{}签到完成".format(uname))
92101
u3 += "<br>" + uname + "签到完成"
93102
u3 = quote(u3, 'utf-8')
94103
pushMsg(u3h + u3)

0 commit comments

Comments
 (0)