python 手机App数据抓取实战一
前言
当前手机使用成为互联网主流,每天手机App产生大量数据,学习爬虫的人也不能只会爬取网页数据,我们需要学习如何从手机 APP 中获取数据,本文就以豆果美食为例,讲诉爬取手机App的流程
环境准备
- python3
- fiddler
- 一款支持桥接模式的安卓虚拟机(本文使用夜神模拟器)
需要准备的知识有:
- requests的使用
- mongodb的使用
- fiddler抓包工具的基本操作
- 线程池ThreadPoolExecutor的基本使用
项目开始
我们项目的目标是将豆果美食App中所有的菜谱都抓取下来到我们的本地数据库中
本文不再讲解fiddler、安卓模拟器、以及某些python第三方库的安装,不会的同学可以百度,非常简单的操作
我们抓取的流程大概就是
- 安卓模拟器使用代理连接至fiddler
- 打开安卓模拟器进行操作
- 分析fiddler抓到的数据
- 使用python模拟数据给服务器发送request请求得到响应数据
- 使用多线程抓取并在本地保存至数据库
1)安卓模拟器使用代理连接至fiddler
打开fiddler,进行设置 打开最上方菜单栏中的 Tools 菜单中的 Options 选项 即配置选项进行以下配置(主要就是前3项的配置)



第三张图片中的8889就是我们fiddler监听的端口号,一会我们将模拟器配置代理就可以从fiddler中抓取数据包
打开安卓模拟器的网络连接的桥接模式(夜神模拟器包括此功能,此步骤需要重启),使用夜神的童鞋推荐使用android4 以为我一开始使用android5发现桥接模式无法联网

然后我们现在看下我们电脑的IP地址 打开命令行输入 ipconfig 命令即可
例如当前我的地址为 172.20.10.2 那么打开安卓模拟器的设置中的无线连接选项,长按网络名称如下图出现修改网络选项 接下来选择高级设置添加手动代理 将自己电脑的IP与fiddler中的端口号输入


接下来测试是否能连接到fiddler 打开fiddler 然后安卓模拟器打开浏览器随便开一个网页,看看fiddler是否可以抓到包

发现现在是可以抓到数据包的,但是浏览器一直在提醒安全证书有问题,这是因为我们模拟器中没有添加fiddler的证书,我们可以在模拟器浏览器中访问我们电脑的IP地址和端口号来安装证书
点击图中的最下方的超链接下载证书 然后安装证书,注意这一步可能需要我们设置下模拟器的锁屏密码自己设置即可


至此我们第一步模拟器连接到fiddler已经完成,接下来可以进行抓取的操作了
2)打开安卓模拟器进行操作
模拟器安装好豆果美食app开始操作 进入App (图一) 点击菜谱分类(即index页面(图二)) 点进去具体食材(图三)然后选择菜谱(图四)




分别进行以上操作后我们的fiddler就会抓取到很多数据包 然后我们现在打开fiddler来分析下到底是哪些数据包对我们有用
3)分析fiddler抓取的数据
我们先来看下这时候fiddler中出现了什么 看起来很多数据包不知道如何下手

学过编程的同学们都知道一般程序的请求数据都是通过api接口的,我们发现fiddler中抓取到一些名称为 api.douguo.net 的数据包 我们来看看是不是我们想要的数据包
我们点击名称以api 接口的几个数据包就会发现里面返回的数据正是我们想要的数据(出现了分类茄子等内容的数据),所以我们现在将其他没用的数据包删掉,只留下对我们有用的数据包
并且我们根据某些数据包的url名称也会看出点东西,因为编程的命名一般不会杂乱无章的,所以有些名称直接就暴露了数据包的内容
最后我们简单的用fiddler看返回的response可以看出来我们需要用的就是以下三个 返回的数据分别对应着刚刚模拟器操作的图二图三图四 也正是菜谱的内容

4)使用python模拟数据给服务器发送request请求得到响应数据
现在我们对于抓取到的三个包的request分析进行模拟,向服务器发送请求,看看我们能否收到想要的响应
打开pycharm 编写文件 首先我们分析第一个包 也就是菜谱分类页面如下图


可以看出来request请求是 POST 方法 头部信息和发送的data 都在fiddler中可以看出来 现在编写py文件
将头部信息复制到notepad或者其他文本处理工具中将文本使用查找替换成我们要的字典格式如图(记得将空格删除)

douguo_test.py文件编写如下:
import requests
import json def douguo_request(url,data):
#有些头部信息不需要已经进行了注释,因为可能会造成服务器检测我们多次请求问题
headers = {
"client": "",
"version": "6945.4",
"device": "OPPO R11",
"sdk": "19,4.4.2",
"imei": "",
"channel": "baidu",
#"mac": "3C:A0:67:68:D1:F5",
"resolution": "1280*720",
"dpi": "1.5",
#"android-id": "3ca06768d1f58615",
#"pseudo-id": "768d1f586153ca06",
"brand": "OPPO",
"scale": "1.5",
"timezone": "",
"language": "zh",
"cns": "",
"carrier": "CMCC",
#"imsi": " 460076016067682",
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; OPPO R11 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36",
"act-code": "9d77be448da77d86aa48ae9d822d70d0",
"act-timestamp": "",
"uuid": "b2db10e9-cb21-4c36-ba4c-be62d8b3c67c",
"newbie": "",
"reach": "",
#"lon": "112.573081",
#"lat": "37.735522",
#"cid": "140100",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Accept-Encoding": "gzip, deflate",
"Connection": "Keep-Alive",
#"Cookie": "duid=61248941",
"Host": "api.douguo.net",
#"Content-Length": "68",
} response = requests.post(url=url,data=data,headers=headers)
return response url = 'http://api.douguo.net/recipe/flatcatalogs'
data = {
"client":"",
#"_session" : "1568947372977863254011601605",
#"v" : "1568891837",
"_vs" : ""
} response = douguo_request(url,data)
print(response.text)
然后我们发现打印出一个json格式的东西,接下来我们将打印的东西放进 json.cn网站中读取一下(这样可以更方便的看json数据)

我们发现没错正是我们想要的分类数据 接下来继续下一步的操作
我们点开三个数据包会发现三个数据包的头部信息与POST方法都一样,不一样的是请求的 url 和 data 内容 所以我们编写的第一个request函数可以反复使用
第一个我们已经可以得到页面索引,现在我们来看如何进入具体食材的列表视图 如茄子 分析第二个数据包发送的data 发现data中存在些乱码,这是url编码后的结果,我们转换一下就好了

因此我们发现,其实data就是发送了具体食材的名称,那么名称从哪里获取的呢?没错就是我们刚刚返回的json中就包含,因此我们需要编写一个可以分析json结构获取名称然后组成data的函数
继续编写如下
import requests
import json def douguo_request(url,data):
#有些头部信息不需要已经进行了注释,因为可能会造成服务器检测我们多次请求问题
headers = {
"client": "",
"version": "6945.4",
"device": "OPPO R11",
"sdk": "19,4.4.2",
"imei": "",
"channel": "baidu",
#"mac": "3C:A0:67:68:D1:F5",
"resolution": "1280*720",
"dpi": "1.5",
#"android-id": "3ca06768d1f58615",
#"pseudo-id": "768d1f586153ca06",
"brand": "OPPO",
"scale": "1.5",
"timezone": "",
"language": "zh",
"cns": "",
"carrier": "CMCC",
#"imsi": " 460076016067682",
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; OPPO R11 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36",
"act-code": "9d77be448da77d86aa48ae9d822d70d0",
"act-timestamp": "",
"uuid": "b2db10e9-cb21-4c36-ba4c-be62d8b3c67c",
"newbie": "",
"reach": "",
#"lon": "112.573081",
#"lat": "37.735522",
#"cid": "140100",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Accept-Encoding": "gzip, deflate",
"Connection": "Keep-Alive",
#"Cookie": "duid=61248941",
"Host": "api.douguo.net",
#"Content-Length": "68",
} response = requests.post(url=url,data=data,headers=headers)
return response def douguo_index():
url = 'http://api.douguo.net/recipe/flatcatalogs'
data = {
"client":"",
#"_session" : "1568947372977863254011601605",
#"v" : "1568891837",
"_vs" : ""
}
response = douguo_request(url, data)
#需要把json数据变为dict
response_dict = json.loads(response.text)
for item1 in response_dict['result']['cs']:
for item2 in item1['cs']:
for item3 in item2['cs']:
data={
"client": "",
# "_session": "1568947372977863254011601605",
"keyword": item3['name'],
"_vs": ""
}
print(data) douguo_index()
运行得到如下图

没错我们现在已经构建好了要发送的data数据
接下来我们继续构造另一个发送的函数 来获取具体食材的菜谱列表(我们只选取食材的最火的前10个菜谱) 当前我们先测试第一个获取的也就是茄子,一会我们使用队列来多线程抓取
import requests
import json def douguo_request(url,data):
#有些头部信息不需要已经进行了注释,因为可能会造成服务器检测我们多次请求问题
headers = {
"client": "",
"version": "6945.4",
"device": "OPPO R11",
"sdk": "19,4.4.2",
"imei": "",
"channel": "baidu",
#"mac": "3C:A0:67:68:D1:F5",
"resolution": "1280*720",
"dpi": "1.5",
#"android-id": "3ca06768d1f58615",
#"pseudo-id": "768d1f586153ca06",
"brand": "OPPO",
"scale": "1.5",
"timezone": "",
"language": "zh",
"cns": "",
"carrier": "CMCC",
#"imsi": " 460076016067682",
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; OPPO R11 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36",
"act-code": "9d77be448da77d86aa48ae9d822d70d0",
"act-timestamp": "",
"uuid": "b2db10e9-cb21-4c36-ba4c-be62d8b3c67c",
"newbie": "",
"reach": "",
#"lon": "112.573081",
#"lat": "37.735522",
#"cid": "140100",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Accept-Encoding": "gzip, deflate",
"Connection": "Keep-Alive",
#"Cookie": "duid=61248941",
"Host": "api.douguo.net",
#"Content-Length": "68",
} response = requests.post(url=url,data=data,headers=headers)
return response def douguo_index():
url = 'http://api.douguo.net/recipe/flatcatalogs'
data = {
"client":"",
#"_session" : "1568947372977863254011601605",
#"v" : "1568891837",
"_vs" : ""
}
response = douguo_request(url, data)
#需要把json数据变为dict
response_dict = json.loads(response.text)
for item1 in response_dict['result']['cs']:
for item2 in item1['cs']:
for item3 in item2['cs']:
data={
"client": "",
# "_session": "1568947372977863254011601605",
"keyword": item3['name'],
"_vs": ""
}
return data def douguo_item(data):
print('当前处理食材', data['keyword'])
url = 'http://api.douguo.net/search/universalnew/0/10'
response = douguo_request(url=url,data=data)
print(response.text) douguo_item(douguo_index())
又输出了一个json数据,接着我们放进网页查看

现在我们已经得到了菜谱的作者、介绍等信息但是没有菜谱的详细信息,我们可以进行简单的赋值操作

但是现在我们并没有需要的原料和具体的制作步骤,所以接下来我们分析最后一个数据包,可以得到具体的原料,制作步骤等信息

可以发现同样的我们只需要修改数据包发送的data的部分数据就可以,同上面方法类似继续编写程序然后给字典对象赋值
import requests
import json def douguo_request(url,data):
#有些头部信息不需要已经进行了注释,因为可能会造成服务器检测我们多次请求问题
headers = {
"client": "",
"version": "6945.4",
"device": "OPPO R11",
"sdk": "19,4.4.2",
"imei": "",
"channel": "baidu",
#"mac": "3C:A0:67:68:D1:F5",
"resolution": "1280*720",
"dpi": "1.5",
#"android-id": "3ca06768d1f58615",
#"pseudo-id": "768d1f586153ca06",
"brand": "OPPO",
"scale": "1.5",
"timezone": "",
"language": "zh",
"cns": "",
"carrier": "CMCC",
#"imsi": " 460076016067682",
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; OPPO R11 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36",
"act-code": "9d77be448da77d86aa48ae9d822d70d0",
"act-timestamp": "",
"uuid": "b2db10e9-cb21-4c36-ba4c-be62d8b3c67c",
"newbie": "",
"reach": "",
#"lon": "112.573081",
#"lat": "37.735522",
#"cid": "140100",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Accept-Encoding": "gzip, deflate",
"Connection": "Keep-Alive",
#"Cookie": "duid=61248941",
"Host": "api.douguo.net",
#"Content-Length": "68",
} response = requests.post(url=url,data=data,headers=headers)
return response def douguo_index():
url = 'http://api.douguo.net/recipe/flatcatalogs'
data = {
"client":"",
#"_session" : "1568947372977863254011601605",
#"v" : "1568891837",
"_vs" : ""
}
response = douguo_request(url, data)
#需要把json数据变为dict
response_dict = json.loads(response.text)
for item1 in response_dict['result']['cs']:
for item2 in item1['cs']:
for item3 in item2['cs']:
data={
"client": "",
# "_session": "1568947372977863254011601605",
"keyword": item3['name'],
"_vs": ""
}
return data def douguo_item(data):
item_index_number = 0
print('当前处理食材', data['keyword'])
url = 'http://api.douguo.net/search/universalnew/0/10'
list_response = douguo_request(url=url,data=data)
list_response_dict = json.loads(list_response.text)
for item in list_response_dict['result']['recipe']['recipes']:
item_index_number = item_index_number + 1
#创建一个字典对象用来存放数据
caipu_info = {}
caipu_info['shicai'] = data['keyword']
caipu_info['author'] = item['an']
caipu_info['shicai_id'] = item['id']
caipu_info['shicai_name'] = item['n']
caipu_info['describe'] = item['cookstory']
caipu_info['cailiao_list'] = item['major']
#更多细节需要继续编写请求
detail_url='http://api.douguo.net/recipe/detail/'+str(caipu_info['shicai_id'])
detail_data = {
"client": "",
"_session": "",
"author_id": "",
"_vs": "",
#最下面一条需要我们修改为指定的参数 注意引号与加号写法
"_ext":'{"query":{"id":'+str(caipu_info['shicai_id'])+',"kw":'+str(caipu_info['shicai'])+',"idx":'+str(item_index_number)+',"src":"11101","type":"13"}}'
}
detail_response = douguo_request(url=detail_url,data=detail_data)
detail_response_dict = json.loads(detail_response.text)
caipu_info['tips'] = detail_response_dict['result']['recipe']['tips']
caipu_info['cook_step'] = detail_response_dict['result']['recipe']['cookstep']
print(caipu_info) douguo_item(douguo_index())
现在我们大部分的工作已经完成了,我们已经可以获取到食材的各种信息,接下来就是最后一步了。
5)使用多线程抓取并在本地保存至数据库
大家肯定会发现我们刚刚虽然抓取成功了,但是我们只抓取了茄子的数据,那么还有很多很多的食材菜谱,我们该怎样操作呢?对了就是利用线程池进行多线程抓取提升效率
下面开始编写代码:
import requests
import json
#引入队列
from multiprocessing import Queue
#引入线程池
from concurrent.futures import ThreadPoolExecutor #创建队列
queue_list = Queue() def douguo_request(url,data):
#有些头部信息不需要已经进行了注释,因为可能会造成服务器检测我们多次请求问题
headers = {
"client": "",
"version": "6945.4",
"device": "OPPO R11",
"sdk": "19,4.4.2",
"imei": "",
"channel": "baidu",
#"mac": "3C:A0:67:68:D1:F5",
"resolution": "1280*720",
"dpi": "1.5",
#"android-id": "3ca06768d1f58615",
#"pseudo-id": "768d1f586153ca06",
"brand": "OPPO",
"scale": "1.5",
"timezone": "",
"language": "zh",
"cns": "",
"carrier": "CMCC",
#"imsi": " 460076016067682",
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; OPPO R11 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36",
"act-code": "9d77be448da77d86aa48ae9d822d70d0",
"act-timestamp": "",
"uuid": "b2db10e9-cb21-4c36-ba4c-be62d8b3c67c",
"newbie": "",
"reach": "",
#"lon": "112.573081",
#"lat": "37.735522",
#"cid": "140100",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Accept-Encoding": "gzip, deflate",
"Connection": "Keep-Alive",
#"Cookie": "duid=61248941",
"Host": "api.douguo.net",
#"Content-Length": "68",
} response = requests.post(url=url,data=data,headers=headers)
return response def douguo_index():
url = 'http://api.douguo.net/recipe/flatcatalogs'
data = {
"client":"",
#"_session" : "1568947372977863254011601605",
#"v" : "1568891837",
"_vs" : ""
}
response = douguo_request(url, data)
#需要把json数据变为dict
response_dict = json.loads(response.text)
for item1 in response_dict['result']['cs']:
for item2 in item1['cs']:
for item3 in item2['cs']:
data={
"client": "",
# "_session": "1568947372977863254011601605",
"keyword": item3['name'],
"_vs": ""
}
#放入队列使用put方法
queue_list.put(data) def douguo_item(data):
item_index_number = 0
print('当前处理食材', data['keyword'])
url = 'http://api.douguo.net/search/universalnew/0/10'
list_response = douguo_request(url=url,data=data)
list_response_dict = json.loads(list_response.text)
for item in list_response_dict['result']['recipe']['recipes']:
item_index_number = item_index_number + 1
#创建一个字典对象用来存放数据
caipu_info = {}
caipu_info['shicai'] = data['keyword']
caipu_info['author'] = item['an']
caipu_info['shicai_id'] = item['id']
caipu_info['shicai_name'] = item['n']
caipu_info['describe'] = item['cookstory']
caipu_info['cailiao_list'] = item['major']
#更多细节需要继续编写请求
detail_url='http://api.douguo.net/recipe/detail/'+str(caipu_info['shicai_id'])
detail_data = {
"client": "",
"_session": "",
"author_id": "",
"_vs": "",
#最下面一条需要我们修改为指定的参数 注意引号与加号写法
"_ext":'{"query":{"id":'+str(caipu_info['shicai_id'])+',"kw":'+str(caipu_info['shicai'])+',"idx":'+str(item_index_number)+',"src":"11101","type":"13"}}'
}
detail_response = douguo_request(url=detail_url,data=detail_data)
detail_response_dict = json.loads(detail_response.text)
caipu_info['tips'] = detail_response_dict['result']['recipe']['tips']
caipu_info['cook_step'] = detail_response_dict['result']['recipe']['cookstep']
print('当前处理的菜谱是:',caipu_info['shicai_name'])
print(caipu_info) douguo_index()
#同时进行处理的任务数
pool = ThreadPoolExecutor(max_workers=25)
while(queue_list.qsize()>0):
#注意多线程写法,douguo_item函数后一定不能加括号
pool.submit(douguo_item,queue_list.get())
再次运行,发现现在已经可以抓取所有的菜谱,然后我们只需要进行最后一步将数据保存到本地数据库就彻底大功告成了
我们可以先编写一个入库函数douguo_mongo.py
import pymongo
from pymongo.collection import Collection class Cnonnect_mongo(object):
def __init__(self):
#本地数据库host为127.0.0.1 端口为27017 具体可以打开mongodb查看
self.client = pymongo.MongoClient(host='127.0.0.1',port=27017)
#数据库名称
self.dbdata = self.client['douguomeishi'] def insert_item(self,item):
#数据表名称为 douguo_item
db_collection = Collection(self.dbdata,'douguo_item')
db_collection.insert(item) mongo_info = Cnonnect_mongo()
然后我们去爬虫文件引用刚刚写的入库对象类并使用插入函数
import requests
import json
#引入队列
from multiprocessing import Queue
#引入线程池
from concurrent.futures import ThreadPoolExecutor
#引用入库类对象
from handel_mongo import mongo_info #创建队列
queue_list = Queue() def douguo_request(url,data):
#有些头部信息不需要已经进行了注释,因为可能会造成服务器检测我们多次请求问题
headers = {
"client": "",
"version": "6945.4",
"device": "OPPO R11",
"sdk": "19,4.4.2",
"imei": "",
"channel": "baidu",
#"mac": "3C:A0:67:68:D1:F5",
"resolution": "1280*720",
"dpi": "1.5",
#"android-id": "3ca06768d1f58615",
#"pseudo-id": "768d1f586153ca06",
"brand": "OPPO",
"scale": "1.5",
"timezone": "",
"language": "zh",
"cns": "",
"carrier": "CMCC",
#"imsi": " 460076016067682",
"User-Agent": "Mozilla/5.0 (Linux; Android 4.4.2; OPPO R11 Build/NMF26X) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36",
"act-code": "9d77be448da77d86aa48ae9d822d70d0",
"act-timestamp": "",
"uuid": "b2db10e9-cb21-4c36-ba4c-be62d8b3c67c",
"newbie": "",
"reach": "",
#"lon": "112.573081",
#"lat": "37.735522",
#"cid": "140100",
"Content-Type": "application/x-www-form-urlencoded; charset=utf-8",
"Accept-Encoding": "gzip, deflate",
"Connection": "Keep-Alive",
#"Cookie": "duid=61248941",
"Host": "api.douguo.net",
#"Content-Length": "68",
} response = requests.post(url=url,data=data,headers=headers)
return response def douguo_index():
url = 'http://api.douguo.net/recipe/flatcatalogs'
data = {
"client":"",
#"_session" : "1568947372977863254011601605",
#"v" : "1568891837",
"_vs" : ""
}
response = douguo_request(url, data)
#需要把json数据变为dict
response_dict = json.loads(response.text)
for item1 in response_dict['result']['cs']:
for item2 in item1['cs']:
for item3 in item2['cs']:
data={
"client": "",
# "_session": "1568947372977863254011601605",
"keyword": item3['name'],
"_vs": ""
}
#放入队列使用put方法
queue_list.put(data) def douguo_item(data):
item_index_number = 0
print('当前处理食材', data['keyword'])
url = 'http://api.douguo.net/search/universalnew/0/10'
list_response = douguo_request(url=url,data=data)
list_response_dict = json.loads(list_response.text)
for item in list_response_dict['result']['recipe']['recipes']:
item_index_number = item_index_number + 1
#创建一个字典对象用来存放数据
caipu_info = {}
caipu_info['shicai'] = data['keyword']
caipu_info['author'] = item['an']
caipu_info['shicai_id'] = item['id']
caipu_info['shicai_name'] = item['n']
caipu_info['describe'] = item['cookstory']
caipu_info['cailiao_list'] = item['major']
#更多细节需要继续编写请求
detail_url='http://api.douguo.net/recipe/detail/'+str(caipu_info['shicai_id'])
detail_data = {
"client": "",
"_session": "",
"author_id": "",
"_vs": "",
#最下面一条需要我们修改为指定的参数 注意引号与加号写法
"_ext":'{"query":{"id":'+str(caipu_info['shicai_id'])+',"kw":'+str(caipu_info['shicai'])+',"idx":'+str(item_index_number)+',"src":"11101","type":"13"}}'
}
detail_response = douguo_request(url=detail_url,data=detail_data)
detail_response_dict = json.loads(detail_response.text)
caipu_info['tips'] = detail_response_dict['result']['recipe']['tips']
caipu_info['cook_step'] = detail_response_dict['result']['recipe']['cookstep']
print('当前处理的菜谱是:',caipu_info['shicai_name'])
#保存到数据库
mongo_info.insert_item(caipu_info) douguo_index()
#同时进行处理的任务数
pool = ThreadPoolExecutor(max_workers=25)
while(queue_list.qsize()>0):
#注意多线程写法,douguo_item函数后一定不能加括号
pool.submit(douguo_item,queue_list.get())
运行,我们的数据就保存在数据库了


这就是爬取一个App的整个流程,有点繁琐,但也很有趣,一步一步的解析数据,挺有挑战性的。
python 手机App数据抓取实战一的更多相关文章
- python 手机App数据抓取实战二抖音用户的抓取
前言 什么?你问我国庆七天假期干了什么?说出来你可能不信,我爬取了cxk坤坤的抖音粉丝数据,我也不知道我为什么这么无聊. 本文主要记录如何使用appium自动化工具实现抖音App模拟滑动,然后分析数据 ...
- Python爬虫入门教程 29-100 手机APP数据抓取 pyspider
1. 手机APP数据----写在前面 继续练习pyspider的使用,最近搜索了一些这个框架的一些使用技巧,发现文档竟然挺难理解的,不过使用起来暂时没有障碍,估摸着,要在写个5篇左右关于这个框架的教程 ...
- python 手机app数据爬取
目录 一:爬取主要流程简述 二:抓包工具Charles 1.Charles的使用 2.安装 (1)安装链接 (2)须知 (3)安装后 3.证书配置 (1)证书配置说明 (2)windows系统安装证书 ...
- Python爬虫工程师必学——App数据抓取实战 ✌✌
Python爬虫工程师必学——App数据抓取实战 (一个人学习或许会很枯燥,但是寻找更多志同道合的朋友一起,学习将会变得更加有意义✌✌) 爬虫分为几大方向,WEB网页数据抓取.APP数据抓取.软件系统 ...
- Python爬虫工程师必学APP数据抓取实战✍✍✍
Python爬虫工程师必学APP数据抓取实战 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大 ...
- Python爬虫工程师必学——App数据抓取实战
Python爬虫工程师必学 App数据抓取实战 整个课程都看完了,这个课程的分享可以往下看,下面有链接,之前做java开发也做了一些年头,也分享下自己看这个视频的感受,单论单个知识点课程本身没问题,大 ...
- python&php数据抓取、爬虫分析与中介,有网址案例
近期在做一个网络爬虫程序.后台使用python不定时去抓取数据.前台使用php进行展示 站点是:http://se.dianfenxiang.com
- python 3 Urllib 数据抓取
1.0 Urllib简介 Urllib是python自带的标准库,无需安装,直接引用即可.urllib通常用于爬虫开发,API(应用程序编程接口)数据获取和测试.在python2和python3中,u ...
- python爬虫数据抓取方法汇总
概要:利用python进行web数据抓取方法和实现. 1.python进行网页数据抓取有两种方式:一种是直接依据url链接来拼接使用get方法得到内容,一种是构建post请求改变对应参数来获得web返 ...
随机推荐
- mysql授权访问数据库
授权给mysql权限 将所有的权限赋值给某个用户 grant all privileges on *.* to username@"%" identified by 'passwo ...
- 页面性能优化:preload预加载静态资源
本文主要介绍preload的使用,以及与prefetch的区别.然后会聊聊浏览器的加载优先级. preload 提供了一种声明式的命令,让浏览器提前加载指定资源(加载后并不执行),在需要执行的时候再执 ...
- Uber如何搭建一个基于Kafka的跨数据中心复制平台 原创: 徐宏亮 AI前线 今天
Uber如何搭建一个基于Kafka的跨数据中心复制平台 原创: 徐宏亮 AI前线 今天
- delphi 获得父目录–指定级父目录
function get_dir_parent(dir:string;n:integer):string; //n为几级父目录varst:string;i:integer;begin st:=GetC ...
- Matrix学习
package com.loaderman.customviewdemo; import android.app.Activity; import android.graphics.ColorMatr ...
- connections java.net.BindException: Address already in use_解决方案
一.问题描述 在Linux服务器(CentOS7系统)中配置并启动JMeter远程监控服务器资源所需的ServerAgent目录下的 startAgent.sh 文件时,系统出现异常提示,如 [roo ...
- utf-8的中文是一个字符占几个字节
utf-8的中文是一个字符占几个字节 英文字母和中文汉字在不同字符集编码下的字节数英文字母:·字节数 : 1;编码:GB2312 字节数 : 1;编码:GBK 字节数 : 1;编码:GB18030 字 ...
- 阶段5 3.微服务项目【学成在线】_day18 用户授权_08-动态查询用户的权限-用户中心查询用户权限
3.3 用户中心查询用户权限 3.3.1 需求分析 认证服务请求用户中心查询用户信息,用户需要将用户基本信息和用户权限一同返回给认证服务. 本小节实现用户查询查询用户权限,并将用户权限信息添加到的用户 ...
- 阶段5 3.微服务项目【学成在线】_day17 用户认证 Zuul_02-用户认证-认证服务查询数据库-需求分析&搭建环境
1.2 认证服务查询数据库 1.2.1 需求分析 认证服务根据数据库中的用户信息去校验用户的身份,即校验账号和密码是否匹配. 认证服务不直接连接数据库,而是通过用户中心服务去查询用户中心数据库. 完整 ...
- Mysql5.7数据库介绍
(1).默认数据库介绍 information_schema 这个数据库保存了Mysql服务器所有数据库的信息.如数据库名.数据库的表.表栏的数据类型访问权限等. mysql 这个库是系统库,里面保存 ...