ming 3 年之前
父節點
當前提交
c8dc01484d

+ 27 - 0
69592a86-ed3b-477e-8060-39af32d8ec49.json

@@ -0,0 +1,27 @@
+
+    {
+       "access_token":"ya29.A0ARrdaM-8J7urxGZFJBi4jt4ORkrCofDLMI3SN_jNfFjt5HlRZnlQ_FCRqQNZupdR0HWhAgzOE92p-AjAaBpKwklGQGxM5m3byAjQsr8qHr237p1lsdWif0kffHt2wpNxowuy5UyrzxbrSsj0zmuzZ5JgthRd",
+       "client_id":"184319941539-gdh6p4v400g0f5fj076bp7l3cf7vn7ha.apps.googleusercontent.com",
+       "client_secret":"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",
+       "refresh_token":"1//0e3GKAc0Xl1V1CgYIARAAGA4SNwF-L9IrMmaPcxVGEA6J-yYeVzx8l9C3op0oiga7Ouw-_b7hv3enOhPwEixoH7pY3efL_aY6cSw",
+       "token_expiry":"2020-10-27T18:03:48Z",
+       "token_uri":"https://accounts.google.com/o/oauth2/token",
+       "user_agent":null,
+       "revoke_uri":"https://oauth2.googleapis.com/revoke",
+       "id_token":null,
+       "id_token_jwt":null,
+       "token_response":{
+          "access_token":"1//0e3GKAc0Xl1V1CgYIARAAGA4SNwF-L9IrMmaPcxVGEA6J-yYeVzx8l9C3op0oiga7Ouw-_b7hv3enOhPwEixoH7pY3efL_aY6cSw",
+          "expires_in": 3599,
+          "scope":"https://www.googleapis.com/auth/youtube.upload",
+          "token_type":"Bearer"
+       },
+       "scopes":[
+          "https://www.googleapis.com/auth/youtube.upload"
+       ],
+       "token_info_uri":"https://oauth2.googleapis.com/tokeninfo",
+       "invalid":false,
+       "_class":"OAuth2Credentials",
+       "_module":"oauth2client.client"
+    }
+            

+ 4 - 4
choozmo/term_get_email.py

@@ -16,7 +16,7 @@ import time
 import rpyc
 import sys
 import docker
-import  googlesearch
+# import  googlesearch
 import codecs
 import sys
 import time
@@ -75,10 +75,10 @@ def restart_browser():
     options = webdriver.ChromeOptions()
     options.add_argument("start-maximized")
     options.add_argument('user-data-dir=C:\\Users\\jared\\AppData\\Local\\Google\\Chrome\\User Data')
-#    options.add_argument('--profile-directory=Profile 77')
-    options.add_argument('--profile-directory=Default')
+    # options.add_argument('--profile-directory=Profile 77')
+    # options.add_argument('--profile-directory=Default')
 
-    driver=webdriver.Chrome(chrome_options=options)
+    driver=webdriver.Chrome(options=options,executable_path='C:\\Users\\user\\Downloads\\chromedriver_99\\chromedriver')
     #driver = webdriver.Remote(
     #    command_executor='http://127.0.0.1:4444/wd/hub',
     #desired_capabilities=options.to_capabilities())

+ 5 - 0
hhh/yt/looping.bat

@@ -0,0 +1,5 @@
+:loop
+
+python yt_looping.py
+
+goto loop

+ 56 - 0
hhh/yt/scan2.py

@@ -0,0 +1,56 @@
+import os
+import sys
+import dataset
+import codecs
+
+fname_dict={}
+#fulllst=['#31','#32','#33','#34','#35','#36','#37','#38','#39','#40','#41','#42']
+fulllst=['#49','#50','#51','#52','#53','#54','#55']
+
+
+fr=codecs.open('c:/tmp/ytfiles.csv','r','utf-8')
+lines=fr.readlines()
+fr.close()
+## .mp4 -> yid
+fname_yiddict={}
+for l in lines:
+    elmts=l.split(',')
+    if len(elmts[2])>10:
+        fname_yiddict[elmts[0].lower().replace('\r','').replace('\n','')]=elmts[2].replace('\r','').replace('\n','').replace("http://youtu.be/",'').replace("https://youtu.be/",'')
+
+
+for lst_elmt in fulllst:
+    lst=os.listdir('O:\\【完整版】幸福空間節目\\'+lst_elmt)
+    for l in lst:
+        fname_dict[l]='O:\\【完整版】幸福空間節目\\'+lst_elmt+"\\"+l
+        print(l)
+        print('O:\\【完整版】幸福空間節目\\'+lst_elmt+"\\"+l)
+
+
+db2 = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
+table=db2['yt_tasks2']
+db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@127.0.0.1:13317/xoops?charset=utf8mb4')
+
+# yid -> detail
+yiddict={}
+cursor=db.query('select youtube_video_id,title,description from youtube_list')
+title=None
+desc=None
+for c in cursor:
+#    print(c['youtube_video_id'])
+    yiddict[c['youtube_video_id']]=c
+#    title=c['title']
+#    desc=c['description']
+
+for k,v in fname_yiddict.items():
+#    print(k)
+#    print(v)
+    if yiddict.get(v):
+        if fname_dict.get(k):
+            table.insert({'fname':k,'path':fname_dict[k],'yid':yiddict[v]['youtube_video_id'],'title':yiddict[v]['title'],'desc':yiddict[v]['description']})
+            print(k)
+            print(fname_dict[k])
+            print(yiddict[v]['youtube_video_id'])
+            print(yiddict[v]['title'])
+
+#print(lst)

+ 55 - 0
hhh/yt/scandisk.py

@@ -0,0 +1,55 @@
+import os
+import sys
+import dataset
+import codecs
+
+fname_dict={}
+fulllst=['#31','#32','#33','#34','#35','#36','#37','#38','#39','#40','#41','#42']
+
+
+fr=codecs.open('c:/tmp/ytfiles.csv','r','utf-8')
+lines=fr.readlines()
+fr.close()
+## .mp4 -> yid
+fname_yiddict={}
+for l in lines:
+    elmts=l.split(',')
+    if len(elmts[2])>10:
+        fname_yiddict[elmts[0].lower().replace('\r','').replace('\n','')]=elmts[2].replace('\r','').replace('\n','').replace("http://youtu.be/",'').replace("https://youtu.be/",'')
+
+
+for lst_elmt in fulllst:
+    lst=os.listdir('P:\\【完整版】幸福空間節目\\'+lst_elmt)
+    for l in lst:
+        fname_dict[l]='P:\\【完整版】幸福空間節目\\'+lst_elmt+"\\"+l
+        print(l)
+        print('P:\\【完整版】幸福空間節目\\'+lst_elmt+"\\"+l)
+
+
+db2 = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/hhh?charset=utf8mb4')
+table=db2['yt_tasks']
+db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@127.0.0.1:13317/xoops?charset=utf8mb4')
+
+# yid -> detail
+yiddict={}
+cursor=db.query('select youtube_video_id,title,description from youtube_list')
+title=None
+desc=None
+for c in cursor:
+#    print(c['youtube_video_id'])
+    yiddict[c['youtube_video_id']]=c
+#    title=c['title']
+#    desc=c['description']
+
+for k,v in fname_yiddict.items():
+#    print(k)
+#    print(v)
+    if yiddict.get(v):
+        if fname_dict.get(k):
+            table.insert({'fname':k,'path':fname_dict[k],'yid':yiddict[v]['youtube_video_id'],'title':yiddict[v]['title'],'desc':yiddict[v]['description']})
+            print(k)
+            print(fname_dict[k])
+            print(yiddict[v]['youtube_video_id'])
+            print(yiddict[v]['title'])
+
+#print(lst)

+ 130 - 0
hhh/yt/sel_yt.py

@@ -0,0 +1,130 @@
+import traceback
+from selenium import webdriver
+from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
+import time
+import os
+import datetime
+import urllib.parse
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.common.by import By
+from selenium.webdriver.support import expected_conditions as EC
+from selenium.webdriver.common.keys import Keys
+import codecs
+import random
+import requests
+import time
+import rpyc
+import sys
+import codecs
+import sys
+import time
+import dataset
+import os
+
+
+fr=codecs.open('c:/tmp/ytfiles.csv','r','utf-8')
+lines=fr.readlines()
+fr.close()
+fnamedict={}
+for l in lines:
+    elmts=l.split(',')
+    if len(elmts[2])>10:
+        fnamedict[elmts[0].lower().replace('\r','').replace('\n','')]=elmts[2].replace('\r','').replace('\n','').replace("http://youtu.be/",'').replace("https://youtu.be/",'')
+
+prefix='P:\\【完整版】幸福空間節目\\#31'
+fname='31video_1101.mp4'
+yt=fnamedict[fname.lower()]
+print(yt)
+
+#db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@hhh-v57.cmab1ctkglka.ap-northeast-2.rds.amazonaws.com:3306/xoops?charset=utf8mb4')
+db = dataset.connect('mysql://hhh7796hhh:lYmWsu^ujcA1@127.0.0.1:13317/xoops?charset=utf8mb4')
+
+cursor=db.query('select * from youtube_list where youtube_video_id="'+yt+'"')
+title=None
+desc=None
+for c in cursor:
+    print(c)
+    title=c['title']
+    desc=c['description']
+    break
+
+
+
+
+
+def scrolling(driver,pgnum):
+    ub = driver.find_element_by_css_selector('body')
+    for i in range(pgnum):
+        ub.send_keys(Keys.PAGE_DOWN)
+        if pgnum>1:
+            time.sleep(0.3)
+
+
+def restart_browser():
+#    os.system('docker container restart p4444')
+#    time.sleep(10)
+
+    options = webdriver.ChromeOptions()
+#    options.add_argument("--proxy-server=socks5://130.61.93.198:1080")
+    options.add_argument("start-maximized")
+    options.add_argument('user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data')
+    options.add_argument('--profile-directory=Profile 7')
+
+    driver=webdriver.Chrome(desired_capabilities=options.to_capabilities())
+    driver.set_window_size(1400,1000)
+    return driver
+
+
+driver=restart_browser()
+url='https://www.youtube.com/upload'
+
+driver.get(url)
+time.sleep(5)
+elmt=driver.find_element_by_xpath("//input[@type='file']")
+elmt.send_keys(prefix+"\\"+fname)
+time.sleep(6)
+
+elmts=driver.find_elements_by_xpath("//div[@id='textbox']")
+elmt=elmts[0]
+elmt.click()
+for i in range(20):
+    elmt.send_keys(Keys.BACKSPACE)
+    time.sleep(0.1)
+elmt.send_keys(title)
+time.sleep(1)
+
+elmt=elmts[1]
+elmt.click()
+for i in range(15):
+    elmt.send_keys(Keys.ARROW_UP)
+    time.sleep(0.1)
+elmt.send_keys(Keys.RETURN)
+
+elmt.send_keys(desc)
+time.sleep(1)
+
+elmt=driver.find_element_by_xpath("//*[@id='next-button']")
+elmt.click()
+time.sleep(3)
+
+elmt=driver.find_element_by_xpath("//*[@id='next-button']")
+elmt.click()
+time.sleep(3)
+elmt=driver.find_element_by_xpath("//*[@id='next-button']")
+elmt.click()
+time.sleep(3)
+elmt=driver.find_element_by_xpath("//*[@id='done-button']")
+elmt.click()
+time.sleep(3)
+
+while True:
+    try:
+        elmt=driver.find_element_by_xpath("//span[contains(text(),'檢查完畢,未發現任何問題)]")
+        break
+    except:
+        print('not yet')
+        time.sleep(5)
+#檢查完畢,未發現任何問題。
+
+time.sleep(9999)
+

二進制
ig_tags/__pycache__/ig_tags.cpython-39.pyc


二進制
ig_tags/__pycache__/pd.cpython-39.pyc


二進制
ig_tags/__pycache__/setting.cpython-39.pyc


+ 34 - 21
ig_tags/ig_selenium.py

@@ -16,29 +16,29 @@ import ast
 import pymysql
 
 pymysql.install_as_MySQLdb()
-
-import pd
 import setting
 
 
 account = ['chenlinrain','enjoylisteningswift','novak_goodenough']
 
-account = pd.account
-password = pd.password
+account = 'chenlinrain'
+password = 'weareyoung12'
+
+path = 'C:\\Users\\user\\Downloads\\chromedriver_99\\chromedriver'
 
-path = '/Users/zooeytsai/Downloads/chromedriver'
-sbaccount = account[2]
-sbpd = password[1]
 options = webdriver.ChromeOptions()
-# options.add_argument("--headless") # 視窗背後執行
-options.add_argument("user-agent=%s" % rua())
+options.add_argument("--headless") # 視窗背後執行
+options.add_argument("user-agent=%s" % setting.rua())
+print(setting.rua())
 
 
 def download_post():
-    hashtag = '寵物蛋糕'
+    sbaccount = 'chenlinrain'
+    sbpd = password
+    hashtag = '實體課'
     url = f"https://www.instagram.com/explore/tags/{hashtag}/"
     s = Service(path)
-    driver = webdriver.Chrome(service=s, options=options)
+    driver = webdriver.Chrome(executable_path=path, options=options)
     driver.implicitly_wait(3)
     driver.get('https://www.instagram.com/')
     time.sleep(5)
@@ -52,7 +52,7 @@ def download_post():
     driver.get(url)
     time.sleep(3)
     limit_of_posts = 10
-    limit_of_scroll = 100
+    limit_of_scroll = 40
     c = 0
     c_sroll = 0
     link = []
@@ -84,14 +84,17 @@ def download_post():
 
 
 def hashtag():
-    input_hashtag = 'pet_cake'
+    sbaccount = 'novak_goodenough'
+    sbpd = password
+    input_hashtag = 'face_to_face'
     collect_hashtag = []
     c = 0
+    rest = 0
     f = open('link.txt', 'r')
     result = f.read()
     link = ast.literal_eval(result)
     s = Service(path)
-    driver = webdriver.Chrome(service=s, options=options)
+    driver = webdriver.Chrome(executable_path=path, options=options)
     driver.implicitly_wait(3)
     driver.get('https://www.instagram.com/')
     time.sleep(5)
@@ -105,7 +108,8 @@ def hashtag():
     driver.find_element(By.XPATH, '//*[@id="react-root"]/section/main/div/div/div/section/div/button').click()
     time.sleep(3)
     
-    for url in link:
+    for i,url in enumerate(link):
+        print(i)
         driver.get(f"https://www.instagram.com/{url}")
         soup = BeautifulSoup(driver.page_source, 'html.parser')
         hashtags = soup.find_all('a', class_='xil3i')
@@ -113,33 +117,42 @@ def hashtag():
             print(tag.text)
             collect_hashtag.append(tag.text)
         c += 1
+        rest+=1
         if c > 10:
             time.sleep(randint(5, 10))
             c = 0
+        if rest>100:
+            time.sleep(randint(60,90))
+            rest=0
     driver.close()
     print(collect_hashtag)
+    
     db_company = pymysql.connect(host='db.ptt.cx',
                                  user='choozmo',
                                  password='pAssw0rd',
                                  database='seo')
+    print('開始開始寫進db')
     cur = db_company.cursor()
-    query_new_col = f"ALTER TABLE seo.ig_pet ADD COLUMN {input_hashtag} VARCHAR(45) NULL"
+    query_new_col = f"ALTER TABLE seo.ig_pet_2 ADD COLUMN {input_hashtag} VARCHAR(45) NULL"
     cur.execute(query_new_col)
     id_number = 0
-    cur.execute("select * from seo.ig_pet order by `index` desc limit 1")
+    cur.execute("select * from seo.ig_pet_2 order by `id` desc limit 1")
     last_id = cur.fetchall()[0][0]
     insert_row = len(collect_hashtag) - last_id
     for i in range(0, insert_row):
-        query_insert = f"INSERT INTO seo.ig_pet ({input_hashtag}) VALUES ('')"
+        query_insert = f"INSERT INTO seo.ig_pet_2 ({input_hashtag}) VALUES ('')"
         cur.execute(query_insert)
+        db_company.commit()
+        print(i)
     for i in collect_hashtag:
         i = i.replace('#', '')
-        query_update = f"UPDATE seo.ig_pet SET {input_hashtag}='{i}' where `index`='{id_number}'"
+        query_update = f"UPDATE seo.ig_pet_2 SET {input_hashtag}='{i}' where `id`='{id_number}'"
         cur.execute(query_update)
         id_number += 1
-    
-    db_company.commit()
+        db_company.commit()
+        print(i,id_number)
     db_company.close()
+    print(len(link))
     return hashtag
 
 

File diff suppressed because it is too large
+ 0 - 0
ig_tags/link.txt


Some files were not shown because too many files changed in this diff