吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 6693|回复: 28
收起左侧

[Python 原创] 【原创】关于我为了找女朋友,使用python爬取一罐求撩区cpdd这件事part1

  [复制链接]
沧浪之水濯我心 发表于 2022-1-2 13:57
本帖最后由 沧浪之水濯我心 于 2022-1-2 17:05 编辑

【原创】关于我为了找女朋友,使用python爬取一罐求撩区这件事part1


一、前言
(一)一罐app简介
一罐app 是一款小众交友软件,可以匿名or真身发布动态进行cpdd
(二)开发本程序的目的
为了更方便的cpdd(其实是瞎吉尔开发的)
(三)本项目使用的环境
1.python3.9
2.mysql(可选)
3.Thor 我是苹果手机,使用Thor抓包的,接口为/feed/list
(四)使用方法
代码写的简陋,但是能跑就行了
使用本项目需要你自己会抓包,并且懂得一点python,会自行替换代码中的参数,需要替换的我都备注了


二、代码
[Python] 纯文本查看 复制代码
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import json
import time
import requests
from datetime import datetime
import mysql.connector
 
#请求头
headers = {
    'authority': 'api.jijigugu.club',
    'cache-control': 'max-age=0',
    'sec-ch-ua': '" Not A;Brand";v="99", "Chromium";v="96", "Microsoft Edge";v="96"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36 Edg/96.0.1054.62',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
    'sec-fetch-site': 'none',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-user': '?1',
    'sec-fetch-dest': 'document',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6'
}
 
global lastScore, count, create_time, info_result,info_result_sql
lastScore = ""
info_result = ""
count = 1
create_time = int(time.time())
info_result_sql=[]
url = 'https://api.jijigugu.club/feed/list'
 
#获取json
def getInfo(Score):
    params = (
        ('age', '["80+","80-","90+","00+","95+","05+","85+"]'),#这里可以自定义年龄段,比如只选择00+,删掉其他的就可以
        ('deviceId', ''),#替换你自己抓包的
        ('dist', 'appstore'),
        ('gender', '[2,1]'),#这里可以选择性别,[2,1]代表男女都选,[2]代表女生
        ('lastScore', Score),#lastScore是定位用的,每次请求都只有几个数据,lastScore可以让你获取更多
        ('mid', 'Db2moNRgpB2pQ4YrOW9w'),#Db2moNRgpB2pQ4YrOW9w代表的是求撩区,不同区有不同的mid,抓包即可获得
        ('model', 'iPhone14,5'),
        ('os_version', '15.0.2'),
        ('platform', '2'),
        ('secondsFromGMT', '28800'),
        ('smDeviceId', ''),#替换你自己抓包的
        ('version', '3.14.2'),
        ('x-jike-device-properties',
         '{"idfv":"","idfa":""}'),#替换你自己抓包的
    )
    r = requests.get(url, headers=headers, params=params)
    t = json.loads(r.text)
    return t
 
#解析
def getList(t):
    global count, create_time, info_result,info_result_sql
    i = 0
    for nickname in t['data']:
        ttext = t['data'][i]['text']
        text=ttext.replace("\n",",").replace(" ","")#这里是为了将动态格式化,替换换行为:,,替换空格,text是动态内容
 
        age = t['data'][i]['age']#年龄段
 
        gender = t['data'][i]['gender']#判断性别
        if gender == 1:
            sex = "男"
        else:
            sex = "女"
 
        nickname = t['data'][i]['nickname']#发罐昵称
 
        #获取发动态时间
        createTime = t['data'][i]['createTime']
        create_time = createTime
        t1 = time.localtime(createTime)
        ctime = time.strftime("%Y-%m-%d %H:%M:%S", t1)
 
        likedNum = t['data'][i]['likedNum']#动态被喜欢数
 
        commentedNum = t['data'][i]['commentedNum']]#动态被评论数
 
        #获取图片
        photo=t['data'][i]['photos']
        purl = ""
        if photo != []:
            j=0
 
            for url in photo:
                turl=photo[j]['url']
                purl += turl+';'
                j+=1
 
        #判断是否真身
        isReal = t['data'][i]['user']['isReal']
        if str(isReal) == "True":
            iR = "真身"
        else:
            iR = "分身"
 
        i += 1
 
        #存入txt
        info = str(count)+','+ str(nickname)+','+ str(iR)+','+str(age)+','+str(sex)+','+ str(ctime)+','+str(likedNum)+','+ str(commentedNum)+','+text+','+str(purl)+'\n'
        info_result += info
        #存入sql
        try:
            info_result_sql.append([count,nickname, iR, age, sex, ctime, likedNum, commentedNum, text, purl])
        except:pass
 
        count += 1
 
 
def main():
    global lastScore
    #1640923200为时间戳,获取到该时间之前的所有动态
    while create_time > 1640923200:
        t = getInfo(lastScore)
        lastScore = t['lastScore']
        getList(t)
 
    #存入sql
    table_name=mysql_Create()
    mysql_Insert(table_name)
 
    #存入txt
    txt()
 
 
#存入txt
def txt():
    with open("test.txt", "w") as f:
        csv_title = "序号", "昵称", "真身", "年龄段", "性别", "创建时间", "喜欢数", "评论数", "内容", "图片地址"
 
        f.write(str(csv_title) + '\n')
        for row in info_result:
            try:
                f.write(str(row))
            except:pass
    f.close()
 
#创建sql表
def mysql_Create():
    now = datetime.now()
    table_name = "YG_" + now.strftime("%Y%m%d_%H%M")#动态现在时间创建表
 
    mydb = mysql.connector.connect(
        host="localhost",
        user="root",
        passwd="",#填你自己的
        database=""#填你自己的
    )
    mycursor = mydb.cursor()
    mycursor.execute("DROP TABLE IF EXISTS %s " % (table_name))
    mycursor.execute("CREATE TABLE %s (count INT,nickname VARCHAR(20), iR VARCHAR(10), age VARCHAR(10), sex VARCHAR(5), ctime VARCHAR(20), likedNum INT, commentedNum INT, text TEXT, purl TEXT)" % (table_name))
    mydb.commit()
    mydb.close()
    return table_name
 
#写入sql表
def mysql_Insert(table_name):
 
    mydb = mysql.connector.connect(
        host="localhost",
        user="root",
        passwd="",#填你自己的
        database=""#填你自己的
    )
    mycursor = mydb.cursor()
    for i in range(len(info_result_sql)):
        try:
            sql = "INSERT INTO %s (count,nickname,iR,age,sex,ctime,likedNum,commentedNum,text,purl) VALUES ('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s')"% (
            table_name,info_result_sql[i][0], info_result_sql[i][1], info_result_sql[i][2], info_result_sql[i][3],
            info_result_sql[i][4], info_result_sql[i][5], info_result_sql[i][6], info_result_sql[i][7],
            info_result_sql[i][8], info_result_sql[i][9])
 
            mycursor.execute(sql)
        except:pass
        mydb.commit()
    mydb.close()
 
if __name__ == "__main__":
    main()



三、成果
1.png






免费评分

参与人数 7吾爱币 +13 热心值 +6 收起 理由
OnlineYx + 1 + 1 热心回复!
yyb414 + 1 + 1 热心回复!
bitpig + 1 + 1 用心讨论,共获提升!
xinji56316 + 1 我很赞同!
zxougweschyjb + 1 + 1 我很赞同!
小色将 + 1 + 1 我很赞同!
苏紫方璇 + 7 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!

查看全部评分

本帖被以下淘专辑推荐:

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

goldli 发表于 2022-1-2 14:53
请把性别写成  Gender

免费评分

参与人数 2吾爱币 +2 收起 理由
夜雨秋灯 + 1 我很赞同!
QingYi. + 1 今日最佳

查看全部评分

yep96 发表于 2022-1-2 20:23
猫神 发表于 2022-1-2 15:03
老哥能不能帮忙试试,有一个药太贵了有点无力承担,但是可以小程序每天签到积分兑换

微信小程序可能比较难,小程序一般使用wx.login()请求一个字符串认证用户,这个是由微信内部算法生成的
猫神 发表于 2022-1-2 14:39
老哥想问下 想实现微信小程序每日自动打卡签到难不难 是不是也要用到python
 楼主| 沧浪之水濯我心 发表于 2022-1-2 14:54
猫神 发表于 2022-1-2 14:39
老哥想问下 想实现微信小程序每日自动打卡签到难不难 是不是也要用到python

嗯,不麻烦的快捷指令也行
猫神 发表于 2022-1-2 15:03
沧浪之水濯我心 发表于 2022-1-2 14:54
嗯,不麻烦的快捷指令也行

老哥能不能帮忙试试,有一个药太贵了有点无力承担,但是可以小程序每天签到积分兑换
huanglang 发表于 2022-1-2 15:20
一罐被封了 想要注销 官方不能注销 有没有方法解决啊
echo1612 发表于 2022-1-2 15:48
所以 ,楼主女朋友找到了吗 (滑稽脸
leipop 发表于 2022-1-2 16:20
厉害厉害
kk1212 发表于 2022-1-2 17:17
技术不错,女朋友表示很满意
菠萝蜜 发表于 2022-1-2 17:46
技术不错,女朋友表示很认同
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-17 23:13

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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