mitmdump爬取得到APP数据信息,存入mongode数据库
环境:win10,安卓9,配置好的mitmdump和相关证书代码:import jsonimport pymongofrom mitmproxy import ctxdef response(flow):# https://entree.igetget.com/ebook2/v1/ranklist/list?requestType=new_rank&count=20...
·
环境:win10,安卓9,配置好的mitmdump和相关证书
代码:
import json
import pymongo
from mitmproxy import ctx
def response(flow):
# https://entree.igetget.com/ebook2/v1/ranklist/list?requestType=new_rank&count=20&max_id=0 # 新书排行链接
url = 'https://entree-ws.igetget.com/ebook2/v1/ranklist/list?requestType=total_rank&count=20&max_id=0' # 热书排行
# 对url的过滤,只有mitmdump捕捉到符合的url以后,才会导出数据
if flow.request.url.startswith(url):
text = flow.response.text
data = json.loads(text)
books = data.get('c').get('data')
for book in books:
data = {
'title': book.get('operating_title'),
'cover': book.get('cover'),
'summary': book.get('other_share_summary'),
'introduce': book.get('book_intro'),
'price': book.get('price')
}
save(data)
ctx.log.info(str(data))
ctx.log.info('------------------------------------------------------------------------------------------------------')
def save(data):
client = pymongo.MongoClient(host='localhost')
db = client.igetget
collection = db.book
if data:
collection.insert(data)
成果:
Ps:有什么问题欢迎大家评论
更多推荐
已为社区贡献1条内容
所有评论(0)