Commit 65edba38 authored by shahriar's avatar shahriar
Browse files

Update comment.py

parent d7b987ff
Pipeline #362 failed with stages
import instaloader
import pymongo
from datetime import timezone
L = instaloader.Instaloader()
L.login('shahriarvelayat', 'shve8864@@')
post = instaloader.Post.from_shortcode(L.context, 'CRWNkkchs2x')
client = pymongo.MongoClient(
"*******************************************")
db = client["instagram-lottry"]
col = db["comments"]
comments_from_loop_including_answers = []
for comment in post.get_comments():
print("Searching : ", comment.id)
search = col.find_one({"comment_id": comment.id})
try:
if search is not None and search["comment_id"]:
print(comment.id, " Already Exist")
else:
temp = {"comment_id": comment.id, "owner_username": comment.owner.username,
"owner_id": comment.owner.userid,
"text": comment.text, "date": comment.created_at_utc.timestamp()}
x = col.update(temp, temp, upsert=True)
print(comment.id, " added")
except:
print("")
# x = col.insert_one({"comment_id":comment.id ,"owner_username" : comment.owner.username ,
# "owner_id":comment.owner.userid, "text":comment.text , "date" : comment.created_at_utc.timestamp() })
# comments_from_loop_including_answers.append(comment)
print(len(comments_from_loop_including_answers))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment