望指正demo的定位,有时候会抽风无法接受我的定位信息

 #! /usr/bin/python3
# -*- coding:UTF- -*-
# time : // :
# file : chuangyue.py
# By 卤蛋
from urllib.parse import quote
import datetime
import requests
import calendar
import sys
import time
import random
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) request = requests.session() d = datetime.datetime.now() StateId = index_html = __file__.replace("requestforCH.py", "") + "index.html"
index_img = __file__.replace("requestforCH.py", "") + "index.jpg" UserAgent_list = [r"Mozilla/5.0 (Linux; Android 8.1.0; Redmi 6 Build/O11019; wv) " +
r"AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.99 Mobile Safari/537.36",
r"Mozilla/5.0 (Linux; Android 4.1.1; Nexus 7 Build/JRO03D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Safari/535.19",
r"Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30",
r"Mozilla/5.0 (Linux; U; Android 6.2; en-gb; GT-P1000 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"] with open(__file__.replace("requestforCH.py", "") + r'cookie.txt', 'r') as file:
cookie = file.read()
cookies = {} # 初始化cookies字典变量
for line in cookie.split(';'): # 按照字符:进行划分读取
# 其设置为1就会把字符串拆分成2份
name, value = line.strip().split('=', )
cookies[name] = value # 为字典cookies添加内容 def UserAgent():
return UserAgent_list[random.randint(, len(UserAgent_list)-)] def locationStateAdd(userid):
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Host": "sqg.cydgsx.com",
"Connection": "Keep-Alive",
"Accept-Encoding": "gzip",
"User-Agent": "okhttp/3.10.0",
}
data = {"params": str({"state": StateId, "user_id": userid})}
response = request.get(
url="https://sqg.cydgsx.com/locationStateAdd",
headers=headers,
data=data,
timeout=,
verify=False)
return response.json() def studentLocationAdd(userid):
headers = {
"Content-Type": "application/x-www-form-urlencoded",
"Host": "sqg.cydgsx.com",
"Connection": "Keep-Alive",
"Accept-Encoding": "gzip",
"User-Agent": r"okhttp/3.10.0",
}
data = {"params": '{"address":"中国广东省广州市海珠区","latitude":"23.09610289210092","longitude":"113.33666163412784","user_id":%s}' % userid}
response = request.post(
url="https://sqg.cydgsx.com/studentLocationAdd",
data=data,
headers=headers,
timeout=,
verify=False)
print("定位:",response.text)
for key, value in response.json().items():
if value == "成功" and key == "meg":
return True
return False def Index(url="https://sqg.cydgsx.com/m/s/log/Index"):
headers = {
"Host": "sqg.cydgsx.com",
"Connection": "keep-alive",
"Upgrade-Insecure-Requests": "",
"User-Agent": UserAgent(),
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
"Referer": url,
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,en-US;q=0.9",
"X-Requested-With": "com.gcykj.boss",
}
temp_cookies = {"chref": url}
temp_cookies.update(cookies)
response = request.get(
url=url,
headers=headers,
cookies=temp_cookies,
timeout=,
verify=False)
html = response.text.replace('href="', 'href="https://sqg.cydgsx.com').replace("'get','", "'get','https://sqg.cydgsx.com").replace(r'src="', 'src="https://sqg.cydgsx.com')
with open(index_html, "w", encoding='utf-8') as file:
file.write(html)
print(locationStateAdd(cookies["LoginUser_Id"].split("&")[])) # 等待服务器添加定位
# studentLocationAdd(cookies["LoginUser_Id"].split("&")[]) # 添加定位
return studentLocationAdd(cookies["LoginUser_Id"].split("&")[]) # 添加定位 def day(string=d.strftime('%Y-%m-%d')): if d.day == getMonthFirstDayAndLastDay()[].day:
month(d.strftime('%Y-%m-%d') + "\n无人值守\n" + "每月小结")
elif d.weekday() == :
week(d.strftime('%Y-%m-%d') + "\n无人值守\n" + "每周周报")
headers = {
"Host": "sqg.cydgsx.com",
"User-Agent": UserAgent(),
"Referer": "https://sqg.cydgsx.com/m/s/log/wLog",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,en-US;q=0.9",
"Accept": "application/json",
"Origin": "https://sqg.cydgsx.com",
"X-Requested-With": "XMLHttpRequest",
"Connection": "keep-alive",
"Content-Type": "application/x-www-form-urlencoded"
} data = {"InternStateId": StateId,
"interContent": quote(string, 'utf-8'),
"logImg": "",
"newlogImg": "",
"posAddress": "",
"posLong": "",
"posLati": ""}
response = request.post(
url="https://sqg.cydgsx.com/m/s/Log/SaveWriteLog",
data=data,
headers=headers,
cookies=cookies,
timeout=,
verify=False)
for key, value in response.json().items():
if value == "成功" and key == "meg":
print("每日小结: ",response.json())
return True
return False def week(string=d.strftime('%Y-%m-%d')):
if d.weekday() != :
return False
else:
headers = {
"Host": "sqg.cydgsx.com",
"Connection": "keep-alive",
"Accept": "application/json",
"Origin": "https://sqg.cydgsx.com",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": UserAgent(),
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "https://sqg.cydgsx.com/m/s/log/wWeekSmy?date={}".format(d.strftime('%Y-%m-%d')),
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,en-US;q=0.9",
}
data = {
"summaryInfo": string,
"logImg": "",
"newlogImg": "",
"smyDate": quote(d.strftime('%Y/%m/%d'),
'utf-8').replace("2F05%",
"2F5%") + "+" + quote("0:00:00", 'utf-8'),
"summaryType": "周小结",
}
response = request.post(
url="https://sqg.cydgsx.com/m/s/Log/SaveSmyJson",
data=data,
headers=headers,
cookies=cookies,
timeout=,
verify=False) for key, value in response.json().items():
if value == "成功" and key == "meg":
print("每周小结: ",response.json())
return True
return False def month(string=d.strftime('%Y-%m-%d')):
if d.day != getMonthFirstDayAndLastDay()[].day:
return False
else:
headers = {
"Host": "sqg.cydgsx.com",
"Connection": "keep-alive",
"Accept": "application/json",
"Origin": "https://sqg.cydgsx.com",
"X-Requested-With": "XMLHttpRequest",
"User-Agent": UserAgent(),
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "https://sqg.cydgsx.com/m/s/log/wMonthSmy?date={}".format(d.strftime('%Y-%m-%d')),
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,en-US;q=0.9",
} data = {
"summaryInfo": string,
"logImg": "",
"newlogImg": "",
"smyDate": quote(d.strftime('%Y/%m/%d'),
'utf-8').replace("%2F0", "%2F") + "+" + quote("22:32:00", 'utf-8'),
"summaryType": "月小结",
}
response = request.post(
url="https://sqg.cydgsx.com/m/s/Log/SaveSmyJson",
data=data,
headers=headers,
cookies=cookies,
timeout=,
verify=False) for key, value in response.json().items():
if value == "成功" and key == "meg":
print("每月小结: ",response.json())
return True
return False def getMonthFirstDayAndLastDay(year=None, month=None):
if year:
year = int(year)
else:
year = datetime.date.today().year if month:
month = int(month)
else:
month = datetime.date.today().month firstDayWeekDay, monthRange = calendar.monthrange(year, month) return [
datetime.date(
year=year,
month=month,
day=),
datetime.date(
year=year,
month=month,
day=monthRange)] def main(data=""):
def setLog(data):
if sys.argv[] == "day":
return day(data + "每日日志")
elif sys.argv[] == "week":
return week(data + "每周周报")
elif sys.argv[] == "month":
return month(data + "每月小结")
if len(sys.argv) > :
return setLog("".join(sys.argv[:]))
elif len(sys.argv) > :
return setLog(data)
else:
return day(data + "每日日志") if __name__ == '__main__':
print("##"*)
# Index("https://sqg.cydgsx.com/m/s/Home/Index")
if main(d.strftime('%Y-%m-%d') + "\n无人值守\n"):
print(d.strftime('%Y-%m-%d %H:%M:%S') + "\t成功写入日志")
print(Index("https://sqg.cydgsx.com/m/s/log/Index"))
else:
print(d.strftime('%Y-%m-%d %H:%M:%S') + "\n写入日志失败")
print("==" * + "\n闯越自动写日志系统(更新版)\tBy:卤蛋 \n2019.05.20·05.31\n" + "==" * )
print("##"*)

基于python3.7的一个闯越自动签到脚本--demo版的更多相关文章

  1. 闯越自动签到demo版补充说明

    demo代码:https://www.cnblogs.com/canmeng/p/11000548.html 定位出错是由于cookie 我重新登录账号过,cookies的值就变了 当时没注意cook ...

  2. Python 实现 T00ls 自动签到脚本(邮件+钉钉通知)

    T00ls 每日签到是可以获取 TuBi 的,由于常常忘记签到,导致损失了很多 TuBi .于是在 T00ls 论坛搜索了一下,发现有不少大佬都写了自己的签到脚本,签到功能实现.定时任务执行以及签到提 ...

  3. 对RoboMaster论坛自动签到脚本制作(虽然没什么用)

    RoboMaster论坛自动签到,自动浏览刷分 不务正业系列 上完最后一节课,队长跟我们说,RM有个BBS,可以看看,但是下载要金币,这个金币只能做签到等事情才能得到,所以我用python做了一个小程 ...

  4. python写的自动签到脚本。

    等以后有时间补上. 附上代码: #! /usr/bin/env python # coding:utf-8 #-----------------------------------------学号和密 ...

  5. 从基于idea的第一个javaweb项目到shell脚本项目自动发布(jdk1.8,mysql5.7,maven3.5,tomcat9,subversion,centos7.3)之一

    首先说一下为什么写这篇文章,因为从正式参加工作就做javaweb开发,一路走来,碰到了很多的问题,每次问题都想从度娘那里得到准确的答案,但是,每个人遇到的问题不尽相同,问题的解决方案有时候也只是仅供参 ...

  6. 搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 (1)

    搭建QQ聊天通信的程序:(1)基于 networkcomms.net 创建一个WPF聊天客户端服务器应用程序 原文地址(英文):http://www.networkcomms.net/creating ...

  7. python3+任务计划实现的人人影视网站自动签到

    python3+任务计划实现的人人影视网站自动签到 这是一个自动化程度较高的程序,运行本程序后会从chrome中读取cookies用于登录人人影视签到, 并且会自动添加一个windows 任务计划,这 ...

  8. Sublime Text 2 (for OS X )配置成可以运行基于python3解释器的 .py文件

    Mac自带的python 其version是python 2.7 官网下的Sublime Text 2部署好了以后默认也是 为了使ST2 可以在command+B时可以运行基于python3的.py, ...

  9. 基于gulp编写的一个简单实用的前端开发环境好了,安装完Gulp后,接下来是你大展身手的时候了,在你自己的电脑上面随便哪个地方建一个目录,打开命令行,然后进入创建好的目录里面,开始撸代码,关于生成的json文件请点击这里https://docs.npmjs.com/files/package.json,打开的速度看你的网速了注意:以下是为了演示 ,我建的一个目录结构,你自己可以根据项目需求自己建目

    自从Node.js出现以来,基于其的前端开发的工具框架也越来越多了,从Grunt到Gulp再到现在很火的WebPack,所有的这些新的东西的出现都极大的解放了我们在前端领域的开发,作为一个在前端领域里 ...

随机推荐

  1. 如何在Eclipse中正确安装Jetty插件并初步使用(图文详解)

    不多说,直接上干货! 最近在做一个Storm项目,需要用到Jetty来进行展示.它类似于Tomcat. 一.eclipse中jetty插件安装 打开eclipse,依次点击菜单Help->Ecl ...

  2. jquery.validate+jquery.form表单验证提交

    1.通过jquery.validate的submitHandler选项,即当表单通过验证时运行回调函数.在这个回调函数中通过jquery.form来提交表单: <script type=&quo ...

  3. HTML5 有哪些不同类型的存储?

    HTML 5 支持本地存储,在之前版本中是通过 Cookie 实现的.HTML5 本地存储速度快而且安全. 有两种不同的对象可用来存储数据: localStorage 适用于长期存储数据,浏览器关闭后 ...

  4. OAuth相关知识

    什么是OAuth认证 1.一种安全认证的协议;2.协议为用户资源的授权提供了一个安全的.开放又简易的标准;3.OAuth的授权不会使第三方触及到用户的账户信息(例如用户名和密码) 网址:www.oau ...

  5. 扒前端网页js代码

    红框是前端代码:输出script中 的内容 可以把红色区域的前端代码 转为java代码 来扒别的网站前端代码 转换成java代码之后,在控制台输入以下代码,点击回车则可以去打印出当前网页上的js fo ...

  6. JSP的使用

    JSP全称为(Java server page),之所以出现JSP,最主要的目的是抽离出Servlet中输出HTML的部分,由于之前响应客户端的时候,是直接在Servlet中利用response.ge ...

  7. 创见VR-上海,会后总结

    第一次,参加这种VR会,感觉不错.上午突然发现自己之前的一款AR Demo下载量在10-50了,真没想到,虽然这款Demo有一处bug至今未修复 ^^.不过,看来现在AR/VR确实恨火. ZSpace ...

  8. shell脚本调试技巧

    shell脚本调试之工具——bashdb http://www.cnblogs.com/itcomputer/p/5011845.html

  9. LeetCode Unique Binary Search Trees (DP)

    题意: 一棵BST有n个节点,每个节点的key刚好为1-n.问此树有多少种不同形态? 思路: 提示是动态规划. 考虑一颗有n个节点的BST和有n-1个节点的BST.从n-1到n只是增加了一个点n,那么 ...

  10. STL中的map和hash_map

    以下全部copy于:http://blog.chinaunix.net/uid-26548237-id-3800125.html 在网上看到有关STL中hash_map的文章,以及一些其他关于STL ...