mitmdump加-s使用python脚本时
程序员文章站
2022-06-02 21:42:16
...
代码内容如下:
import json
import pymongo
from mitmproxy import ctx
client = pymongo.MongoClient('localhost')
db = client['kuaishou']
collection = db['data']
def response(flow):
if '/rest/n/feed/hot' in flow.request.url:
text = flow.response.text
list = json.loads(text)['feeds']
for i in list:
try:
url = i['main_mv_urls'][0]['url']
except KeyError:
continue
data = {
'describe': i['caption'],
'url': url,
'author': i['user_name'],
'id': i['user_id'],
'comments': ''
}
collection.insert(data)
在命令行报错,说pymongo无法找到,这该咋整,求解