From 4047935217daabb786b24a43ffc78a02c13d237a Mon Sep 17 00:00:00 2001 From: liwenwei Date: Thu, 18 Oct 2018 16:07:06 +0800 Subject: [PATCH] Fix the mongodb not authorized on admin to execute command Init the MongoClient with MongoDB connection string URI --- weibo.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/weibo.py b/weibo.py index e64ecbb..70a2f37 100644 --- a/weibo.py +++ b/weibo.py @@ -10,7 +10,10 @@ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36', 'X-Requested-With': 'XMLHttpRequest', } -client = MongoClient() +# Please replace the useradmin, mypassword, host, port with yours +# sample: MdbURI = "mongodb://admin:admin123@localhost:27017/tracking?authSource=admin" +MdbURI = "mongodb://[useradmin]:[mypassword]@[host][:27017]/tracking?authSource=admin" +client = MongoClient(MdbURI) db = client['weibo'] collection = db['weibo'] max_page = 10