jared 10 months ago
parent
commit
a7bce94ef7
1 changed files with 36 additions and 0 deletions
  1. 36 0
      deployment/igtest_login.py

+ 36 - 0
deployment/igtest_login.py

@@ -0,0 +1,36 @@
+from instagrapi import Client
+import re
+import sys
+import dataset
+import datetime
+
+db = dataset.connect('postgresql://postgres:eyJhbGciOiJI@172.105.241.163:5432/postgres')
+table=db['ig_tags']
+
+
+cl = Client()
+cl.login('帳號', '密碼')
+#hashtag = cl.hashtag_info('真理大學')
+#print( hashtag.dict())
+#md=cl.hashtag_medias_recent_v1('真理大學',10)
+#kw='5星評論'
+kw='AI課程'
+
+md=cl.hashtag_medias_recent(kw,30)
+for m in md:
+    dct=m.dict()
+    pk=dct['pk']
+    txt=dct['caption_text']
+#    print(txt)
+    res=re.findall(r"#(\w+)",txt)
+    for r in res:
+        print(r)
+        try:
+            table.insert({'uid':pk,'tag':r,'dt':datetime.datetime.now()})
+        except:
+            print('dup')    
+
+#    if m.get_key('caption_text'):
+#        print(m['caption_text'])
+#caption_text=
+#caption_text=