ming 3 år sedan
förälder
incheckning
8e86aab3ad
1 ändrade filer med 13 tillägg och 12 borttagningar
  1. 13 12
      ig_tags/ig_selenium.py

+ 13 - 12
ig_tags/ig_selenium.py

@@ -14,13 +14,14 @@ from selenium.webdriver.support import expected_conditions as ec
 # import dataset
 import pymysql
 pymysql.install_as_MySQLdb()
-from ig_tags import pd
-from ig_tags import setting
+import pd
+import setting
 
-account = pd.account
-password = pd.password
+account = ['chenlinrain','enjoylisteningswift','novak_goodenough']
 
-path = '/Users/zooeytsai/Downloads/chromedriver'
+password = ['weareyoung12']
+
+path = "C:\\Users\\user\\Downloads\\chromedriver_win32"
 sbaccount = account[1]
 sbpd = password[1]
 options = webdriver.ChromeOptions()
@@ -29,7 +30,7 @@ options.add_argument("user-agent=%s" % setting.rua())
 
 
 def download_post():
-    hashtag = '寵物'
+    hashtag = '寵物鮮食'
     url = f"https://www.instagram.com/explore/tags/{hashtag}/"
     s = Service(path)
     driver = webdriver.Chrome(service=s, options=options)
@@ -83,7 +84,7 @@ def download_post():
 
 
 def hashtag():
-    input_hashtag = 'pilo'
+    input_hashtag = 'pet_food'
     collect_hashtag = []
     c=0
     result = download_post()[0]
@@ -112,12 +113,12 @@ def hashtag():
             c=0
     driver.close()
     print(collect_hashtag)
-    db = pymysql.connect(host='localhost',
-                         user='root',
-                         password='jondae350',
-                         database='ig_tags')
+    db = pymysql.connect(host='db.ptt.cx',
+                         user='choozmo',
+                         password='pAssw0rd',
+                         database='seo')
     cur = db.cursor()
-    query_new_col = f"ALTER TABLE ig_tags.new_table ADD COLUMN {input_hashtag} VARCHAR(45) NULL"
+    query_new_col = f"ALTER TABLE seo.ig_pet ADD COLUMN {input_hashtag} VARCHAR(45) NULL"
     cur.execute(query_new_col)
     id_number = 1
     cur.execute("select * from ig_tags.new_table order by id desc limit 1")