找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 65|回复: 8

LOC云函数挂机求指导,反正我看不懂。。。

[复制链接]

208

主题

317

回帖

1326

积分

金牌会员

积分
1326
发表于 2019-1-20 23:08:19 | 显示全部楼层 |阅读模式
Error 4xx Client Errors 登录后返回的这个页面
回复

使用道具 举报

7

主题

122

回帖

285

积分

中级会员

积分
285
发表于 2019-1-21 08:33:44 | 显示全部楼层
最近规则改了吧
回复

使用道具 举报

303

主题

3626

回帖

8229

积分

论坛元老

积分
8229
发表于 2019-1-20 23:20:25 | 显示全部楼层
s.get和s.post要带headers,把agent和ref属性带上
回复

使用道具 举报

3

主题

441

回帖

915

积分

高级会员

积分
915
发表于 2019-1-20 23:41:49 | 显示全部楼层
错误提示是说
19行这里的正则没有匹配到东西 re.search(r'积分: (\d+).+?', user_info) 为空
所以报NoneType没有group属性的错误

你只能一步一步往上查了
回复

使用道具 举报

179

主题

1158

回帖

2931

积分

金牌会员

积分
2931
发表于 2019-1-21 00:22:31 | 显示全部楼层

yjsx86 发表于 2019-1-21 00:22

错误提示是说
19行这里的正则没有匹配到东西 re.search(r'积分: (\d+).+?', user_info) 为空
所以报NoneTyp ...

就是我说的,要带headers,楼主应该跟我一样用的loc大佬的代码。
回复

使用道具 举报

3

主题

441

回帖

915

积分

高级会员

积分
915
发表于 2019-1-21 00:50:24 | 显示全部楼层
[ol]
  • # -*- coding: utf8 -*-
  • import requests
  • import re
  • from urllib.parse import quote
  • from datetime import *
  • bjtime=str(datetime.utcnow().replace(tzinfo=timezone.utc).astimezone(timezone(timedelta(hours=8)))).split('.')[0]
  • def start():
  •     s = requests.session()
  •     username = '账号账号账号账号'
  •     password = '密码密码密码密码'
  •     headers={
  •         'Host': 'www.hostloc.com',
  •         'Connection': 'keep-alive',
  •         'Cache-Control': 'max-age=0',
  •         'Origin': 'https://www.hostloc.com',
  •         'Upgrade-Insecure-Requests': '1',
  •         'Content-Type': 'application/x-www-form-urlencoded',
  •         'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36',
  •         'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
  •         'Referer': 'https://www.hostloc.com/forum.php',
  •         'Accept-Encoding': 'gzip, deflate',
  •         'Accept-Language': 'zh-HK,zh;q=0.9,zh-CN;q=0.8,en-US;q=0.7,en;q=0.6,zh-TW;q=0.5'
  •     }
  •     login_url = 'https://www.hostloc.com/member.php?mod=logging&action=login&loginsubmit=yes&infloat=yes&lssubmit=yes&inajax=1'
  •     s.post(login_url, {'fastloginfield':'username','quickforward':'yes','handlekey':'1s',"username": username, 'password': password}, headers=headers)
  •     user_info = s.get('https://www.hostloc.com/home.php?mod=spacecp&ac=credit', headers=headers).text
  •     current_money = re.search(r'积分: (\d+).+?', user_info).group(1)
  •     print("用户%s,签到前你的积分为%s" % (username, current_money))
  •     for i in range(20359, 20370):
  •         s.get('https://www.hostloc.com/space-uid-%s.html' % i, headers=headers)
  •     new_money = s.get('https://www.hostloc.com/home.php?mod=spacecp&ac=credit', headers=headers).text
  •     new_money = re.search(r'积分: (\d+).+?', new_money).group(1)
  •     print("用户%s,签到后你的积分为%s" % (username, new_money))
  • def main_handler(event, context):
  •     return start()
  • if __name__ == '__main__':
  •     start()
  • [/ol]复制代码
  • 回复

    使用道具 举报

    208

    主题

    317

    回帖

    1326

    积分

    金牌会员

    积分
    1326
     楼主| 发表于 2019-1-21 00:22:00 | 显示全部楼层

    blanco 发表于 2019-1-21 02:44

    大佬。你这个好像不行~
    回复

    使用道具 举报

    7

    主题

    364

    回帖

    769

    积分

    高级会员

    积分
    769
    发表于 2019-1-21 01:55:24 | 显示全部楼层
    战略mark
    似毛非毛 发表于 2019-1-21 08:32

    大佬。你这个好像不行~

    刚在良心云试了下,用 Python3.6,还要配置超时,改成 10s 测试可以成功。
    回复

    使用道具 举报

    7

    主题

    122

    回帖

    285

    积分

    中级会员

    积分
    285
    发表于 2019-1-21 02:44:15 | 显示全部楼层
    搞了半天没搞定。没去管它。今天自己好了。。
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    Archiver|手机版|小黑屋|Discuz! X

    GMT+8, 2025-4-25 13:07 , Processed in 0.020147 second(s), 4 queries , Gzip On, Redis On.

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

    快速回复 返回顶部 返回列表