pypy
#coding:utf-8 import requests,codecs
import json
import re
import os, shutil
import urllib.request, urllib.error
from requests.cookies import RequestsCookieJar
import time
from PyPDF2 import PdfFileReader, PdfFileWriter, PdfFileMerger
import urllib3
import hashlib
import random class calcSig(object):
key1 = '57218436'
key2 = '15387264'
rstr = 'efc84c17' def shuffle(self, p1, p2):
p = ''
p += p1[int(p2[0], 10) - 1]
p += p1[int(p2[1], 10) - 1]
p += p1[int(p2[2], 10) - 1]
p += p1[int(p2[3], 10) - 1]
p += p1[int(p2[4], 10) - 1]
p += p1[int(p2[5], 10) - 1]
p += p1[int(p2[6], 10) - 1]
p += p1[int(p2[7], 10) - 1]
return p.lower() # 生成 as和cp字段
def ppp(self, u_md5, u_key1, u_key2):
ascp = [0] * 36
ascp[0] = 'a'
ascp[1] = '1'
for i in range(0, 8):
ascp[2 * (i + 1)] = u_md5[i]
ascp[2 * i + 3] = u_key2[i]
ascp[2 * i + 18] = u_key1[i]
ascp[2 * i + 1 + 18] = u_md5[i + 24]
ascp[-2] = 'e'
ascp[-1] = '1' return ''.join(ascp) # 解析url参数
def parseURL(self, url):
param_index = url.find('?')
param = url[param_index + 1:]
param_list = param.split('&')
param_list.append('rstr='+self.rstr)
param_list = sorted(param_list)
result = ''
for a in param_list:
tmp = a.split('=')
tmp[1] = tmp[1].replace('+', 'a')
tmp[1] = tmp[1].replace(' ', 'a')
result += tmp[1]
return result # 计算md5
def calcMD5(self, str_encode):
m = hashlib.md5()
m.update(str_encode.encode('utf-8'))
return m.hexdigest() def work(self, url, curtime):
url_param = self.parseURL(url)
p_md5 = self.calcMD5(url_param)
if curtime & 1:
p_md5 = self.calcMD5(p_md5)
hexTime = hex(curtime)[2:]
aa = self.shuffle(hexTime, self.key1)
bb = self.shuffle(hexTime, self.key2)
sig = self.ppp(p_md5, aa, bb)
return ('%s&as=%s&cp=%s' % (url, sig[:18], sig[18:]))
# return (sig[:18], sig[18:]) def jsppost(url,data):
print('>>> jsp开始 ! \n')
try:
#cookie_jar = RequestsCookieJar()
#c = requests.cookies.RequestsCookieJar()
#s = requests.Session()
#c.set("JSESSIONID", "94E22BF178A02E950FABC28678D0AABA", domain="eresource.library.sh.cn",path="/")
#c.set("JSESSIONID", "A4FD3CC5DD934282AA003EC932399FB7", domain="eresource.library.sh.cn",path='/objserver/')
#s.cookies.update(c)
response = requests.post(url=url,data=data, timeout=120,cookies=c,headers=headers,verify=False) except Exception as e:
print(e) def jsp(url):
print('>>> jsp开始 ! \n')
try:
#cookie_jar = RequestsCookieJar()
c = requests.cookies.RequestsCookieJar()
s = requests.Session()
c.set("JSESSIONID", "94E22BF178A02E950FABC28678D0AABA", domain="eresource.library.sh.cn",path="/")
c.set("JSESSIONID", "A4FD3CC5DD934282AA003EC932399FB7", domain="eresource.library.sh.cn",path='/objserver/')
s.cookies.update(c)
#response = requests.get(url=url, timeout=120,cookies=c,headers=headers,verify=False)
r = requests.get(url=url, timeout=120,headers=headers,verify=False)
tt=json.loads(r.text).get('min_time')
arr=json.loads(r.text).get('followers')
marr=[]
ran=random.randint(5,10)
global cc
cc=cc+1;
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())+' '+str(cc)+' '+str(tt)+' '+str(ran))
for obj in arr:
mdic={'nickname':'','sec_uid':'','uid':'','unique_id':'','short_id':'','share_qrcode_uri':'','avatar_300x300':''}
#print(obj['uid']) mdic['nickname']=obj['nickname']
mdic['sec_uid']=obj['sec_uid']
mdic['uid']=obj['uid']
mdic['short_id']=obj['short_id']
mdic['share_qrcode_uri']=obj['share_qrcode_uri']
mdic['avatar_300x300']=obj['avatar_300x300']['url_list'][0]
marr.append(mdic)
#print(json.loads(r.text).get('followers'))
file = 'dyfs_'+user_id+'.txt'
with open(file,'a+',encoding='utf-8') as f:
f.write(str(marr)+',')
time.sleep(ran)
if tt==-1:
with open(file,'a+',encoding='utf-8') as f:
f.write('\n'+url)
else :
getFollower(str(tt))
except Exception as e:
print(e) def getFollower(max_time):
t = time.time()-dift
#user_id='101817795028'
ts=int(t) #秒级时间戳
_rticket=str(int(round(t * 1000)))
c = calcSig()
url = "https://aweme.snssdk.com/aweme/v1/user/follower/list/?user_id="+user_id+"&max_time="+max_time+"&_rticket="+_rticket+"&ts="+str(ts)+"&count=20&retry_type=no_retry&iid=82879820134&device_id=69189073301&ac=wifi&channel=360_new&aid=1128&app_name=aweme&version_code=168&version_name=1.6.8&device_platform=android&ssmix=a&device_type=Redmi+4A&device_brand=Xiaomi&language=zh&os_api=23&os_version=6.0.1&openudid=29f385a1e0b60ece&manifest_version_code=210&resolution=720*1280&dpi=320&update_version_code=2102"
murl=c.work(url,ts)
print(c.work(url,ts))
jsp(murl) if __name__ == "__main__":
print("加载中....")
DOWNLOAD_PATH = r'E:\\python\\pdf\\' #下载目录
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
#mergefiles(DOWNLOAD_PATH,'out.pdf')
"""
headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36","Referer": "http://wrd2016.library.sh.cn/channel/stjp/?tdsourcetag=s_pcqq_aiomsg"} requests.packages.urllib3.disable_warnings()
jsp('http://eresource.library.sh.cn:8080/objserver/jsp/browserjp.jsp')
time.sleep(0.1) headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36","Referer": "http://eresource.library.sh.cn:8080/objserver/jsp/browserjp.jsp"}
jsp('http://eresource.library.sh.cn:8080/objserver/jsp/fcjp.jsp')
time.sleep(0.1) headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36","Referer": "http://eresource.library.sh.cn:8080/objserver/jsp/browserjp.jsp"}
jsp('http://eresource.library.sh.cn:8080/objserver/jsp/sy.jsp')
time.sleep(0.1) headers = {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36","Referer": "http://eresource.library.sh.cn:8080/objserver/jsp/browserjp.jsp"}
jsp('http://eresource.library.sh.cn:8080/objserver/jsp/fy.jsp')
time.sleep(0.1) fo = open('E:\python\pdf\merged_pdf_file.pdf', "wb")
print("文件名为: ", fo.name)
fo.close()
"""
#"""
users=[{user_id:'101817795028',dyid:'1173509665',nickname:'牛账网会计在线教育'},
{user_id:'62353009337',dyid:'vx284347414',nickname:'会计教练老师实操,做账,报税,考证'},
{user_id:'102664130688',dyid:'chujikuaiji',nickname:'初级会计'},
{user_id:'101817795028',dyid:'1640676212',nickname:'初级会计职称'},
{user_id:'101817795028',dyid:'kuaiji666',nickname:'初级会计考试'},
{user_id:'101817795028',dyid:'chujikuaiji',nickname:''},
{user_id:'101817795028',dyid:'chujikuaiji',nickname:''},
{user_id:'101817795028',dyid:'chujikuaiji',nickname:''}]
user_id='101817795028'#'62353009337'62353009337
cc=0
dift=0
file = 'dyfs_'+user_id+'.txt'
with open(file,'w') as f:
f.write('')
for i in range(1):
#headers = {"Accept":"","Accept-Encoding":"gzip","User-Agent":"com.ss.android.ugc.aweme/750 (Linux; U; Android 6.0.1; zh_CN; Redmi 4A; Build/MMB29M; Cronet/58.0.2991.0)","Cookie": "install_id=82603796791; ttreq=1$1cd2da467f7f9f07d5de1aa593622dc8e06a7c93; odin_tt=cbe4c5411d373bcc1c3d572c33fbd7cd291508f9058b0c999dd5a432c031db5692d05ebc521e96dfce5ebb02201f1934a7bb907f7d37d6a30f308f580d97c3da; qh[360]=1","sdk-version":"1","X-Gorgon":"030428800001f0e89460d16043016864424adf199af7a8b2e148","X-Khronos":"1565712299","X-SS-REQ-TICKET":"1565712299115"}
#headers = {"User-Agent":"com.ss.android.ugc.aweme/750 (Linux; U; Android 6.0.1; zh_CN; Redmi 4A; Build/MMB29M; Cronet/58.0.2991.0)","Cookie": "install_id=82603796791; ttreq=1$1cd2da467f7f9f07d5de1aa593622dc8e06a7c93; odin_tt=cbe4c5411d373bcc1c3d572c33fbd7cd291508f9058b0c999dd5a432c031db5692d05ebc521e96dfce5ebb02201f1934a7bb907f7d37d6a30f308f580d97c3da; qh[360]=1","sdk-version":"1","X-Gorgon":"03e0906d00016fa814d014d60446c7c71713b86fe930f83d8ff5","X-Khronos":"1565778310","X-SS-REQ-TICKET":"1565777837303"}
headers = {"User-Agent":"com.ss.android.ugc.aweme/750 (Linux; U; Android 6.0.1; zh_CN; Redmi 4A; Build/MMB29M; Cronet/58.0.2991.0)","Cookie": "install_id=82879820134; ttreq=1$737084fed40b6240b948d2e5f0895b8df4af9e2f; odin_tt=8c2caed1fe142cfbbdf2a4b5e3fa397d62dbcd9137cc328c4631dfa0c18120d7cb5797df33708d164e7423e4913134028431d801ee758ebef1c15954d9ca470f; qh[360]=1"}
#jsp("https://aweme.snssdk.com/aweme/v1/user/follower/list/?user_id=80954225804&max_time=1565784692&count=20&retry_type=no_retry&mcc_mnc=&iid=82715258125&device_id=69189073301&ac=wifi&channel=360_new&aid=1128&app_name=aweme&version_code=380&version_name=1.8.0&device_platform=android&ssmix=a&device_type=Redmi+4A&device_brand=Xiaomi&language=zh&os_api=23&os_version=6.0.1&openudid=29f385a1e0b60ece&manifest_version_code=380&resolution=720*1280&dpi=320&update_version_code=3802&_rticket=1565784692555&js_sdk_version=1.6.4&mas=0180c7997d71bdad7fd997615978f4f1c98c8c1c4ccc46868c26ec")
#jsp("https://aweme.snssdk.com/aweme/v1/user/follower/list/?user_id=127178283690750&max_time=1565919239&count=20&retry_type=no_retry&iid=82803867752&device_id=38693548692&ac=wifi&channel=360_new&aid=1128&app_name=aweme&version_code=168&version_name=1.6.8&device_platform=android&ssmix=a&device_type=M5+Note&device_brand=Meizu&language=zh&os_api=24&os_version=7.0&uuid=865066037588709&openudid=797cadbbed256853&manifest_version_code=210&resolution=1080*1920&dpi=480&update_version_code=2102&_rticket=1565919256352&ts=1565919256&as=a1a5d0056821ed2806&cp=0818d75184625587e1")
time.sleep(0.2)
t = time.time()-dift
ts=int(t) #秒级时间戳101817795028&max_time=1565927966
max_time=str(ts)
_rticket=str(int(round(t * 1000)))
c = calcSig()
#https://aweme.snssdk.com/aweme/v1/user/follower/list/?user_id=103184660180&max_time=1565923611&count=20&retry_type=no_retry&iid=82879820134&device_id=69189073301&ac=wifi&channel=360_new&aid=1128&app_name=aweme&version_code=210&version_name=2.1.0&device_platform=android&ssmix=a&device_type=Redmi+4A&device_brand=Xiaomi&language=zh&os_api=23&os_version=6.0.1&openudid=29f385a1e0b60ece&manifest_version_code=210&resolution=720*1280&dpi=320&update_version_code=2102&_rticket=1565923611254&ts=1565923609&as=a12521d559b1ad39464355&cp=1a17dc5a9562589be1OaWe&mas=01773fb75f7a5086844863aaf3ed01dcd2acaccc2c6c2c9ccc2686
url = "https://aweme.snssdk.com/aweme/v1/user/follower/list/?user_id="+user_id+"&max_time="+max_time+"&_rticket="+_rticket+"&ts="+str(ts)+"&count=20&retry_type=no_retry&iid=82879820134&device_id=69189073301&ac=wifi&channel=360_new&aid=1128&app_name=aweme&version_code=168&version_name=1.6.8&device_platform=android&ssmix=a&device_type=Redmi+4A&device_brand=Xiaomi&language=zh&os_api=23&os_version=6.0.1&openudid=29f385a1e0b60ece&manifest_version_code=210&resolution=720*1280&dpi=320&update_version_code=2102"
murl=c.work(url,ts)
jsp(murl) #"""
pypy的更多相关文章
- pypy的virtualenv安装mysql的问题解决
pypy安装mysql 构建基于pypy的virtualenv pip install virtualenv pip install pypy virtualenv --no-site-package ...
- 「2014-3-13」Javascript Engine, Java VM, Python interpreter, PyPy – a glance
提要: url anchor (ajax) => javascript engine (1~4 articles) => java VM vs. python interpreter =& ...
- PyPy 2.1 正式版发布
PyPy 2.1 Beta1 才刚刚在2天前发布,今天 PyPy 宣布 2.1 正式版发布. 值得关注的改进内容有: JIT support for ARM, architecture version ...
- Java和PyPy速度对比
Java和PyPy运行同一段代码,对比结果. Java代码: package javatest; import java.text.DecimalFormat; import java.util.Da ...
- Python状况:为什么PyPy是Python的未来?
Python 现在已经不仅仅是胶水脚本语言了. 不信?看看下面使用Python的成功案例: YouTube - 主要由 Python编写 NASA Industrial Light & Mag ...
- 数学之路-python计算实战(2)-初遇pypy
PyPy是Python开发人员为了更好的Hack Python创建的项目.此外,PyPy比CPython是更加灵活,易于使用和试验,以制定详细的功能在不同情况的实现方法,能够非常easy实施. 该项目 ...
- Javascript Engine, Java VM, Python interpreter, PyPy – a glance
提要: url anchor (ajax) => javascript engine (1~4 articles) => java VM vs. python interpreter =& ...
- ubuntu 16.04 部署 pypy+nginx+uwsgi+django(详细)
1.nginx ...
- Python性能优化:PyPy、Numba 与 Cython。PyPy的安装及对应pip的安装
性能优化讨论见参考1:大概意思是,PyPy内置JIT,对纯Python项目兼容性极好,几乎可以直接运行并直接获得性能提升:缺点是对很多C语言库支持性不好.Numba是一个库,可以在运行时将Python ...
- pypy入门:pypy的安装及使用介绍
在做python开发的人,应该或多或少的听说过一点pypy吧.我猜.所以就不做背景介绍了,有不懂的同学可以看看这里: 1.什么是pypy: http://www.360doc.com/content/ ...
随机推荐
- Mysql学习之事务的隔离性
今天咱们说说事务,相信大家都知道事务的 ACID (Atomicity.Consistency.Isolation.Durability,即原子性.一致性.隔离性.持久性). 原子性:表示一个事务不可 ...
- 详解微信公众平台UnionID和OpenID的区别
OpenID: 普通用户的标识,对当前开发者帐号唯一.一个openid对应一个公众号. UnionID :用户统一标识.针对一个微信开放平台帐号下的应用,同一用户的unionid是唯一的. 微信的 ...
- python之变量的数据类型(1)int 、bool 、str 及for循环运用
一.变量的数据类型(1) 1.int 类型 int类型是整数,常用的有bit_length() 方法 用来返回一个数的二进制长度 2.bool类型 布尔型只有两个值 True,False 有关类型转换 ...
- [https][tls] 如何使用wireshark查看tls/https加密消息--使用私钥
之前总结了使用keylog进行https流量分析的方法: [https][tls] 如何使用wireshark查看tls/https加密消息--使用keylog 今天总结一下使用服务器端证书私钥进行h ...
- 191010 python3分数划分ABC等级
# 题目:利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,# 60-89分之间的用B表示,60分以下的用C表示. while True: score = input(" ...
- VueCli3 使用 NutUI (按需加载、定制化主题)
创建vue.config.js module.exports = { css: { loaderOptions: { // 给 sass-loader 传递选项 scss: { // @/ 是 src ...
- 装新的python3.7时ModuleNotFoundError: No module named '_ctypes'
在编译安装新的python3.7的时候 报错 ModuleNotFoundError: No module named '_ctypes',其实是缺少了一个新需要的开发包libffi-devel,安装 ...
- shell文件比较运算符
1.文件比较运算符 -e filename 如果 filename 存在,则为真 [ -e /var/log/syslog ] -d filename 如果 filename 为目录,则为真 [ -d ...
- synchronized(修饰方法和代码块)
synchronized(修饰方法和代码块) 1. 含义 synchronized 是同步锁,用来实现互斥同步. 在 Java 中,关键字 synchronized 可以保证在同一个时刻,只有一个线程 ...
- Python通过lxml库遍历xml通过xpath查询(标签,属性名称,属性值,标签对属性)
xml实例: 版本一: <?xml version="1.0" encoding="UTF-8"?><country name="c ...