12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import dataset
- def insert_db(member):
- dic_tmp = {}
- dic_tmp['kw'] = member[0]
- dic_tmp['page'] = member[1]
- dic_tmp['domain'] = member[2]
- dic_tmp['category'] = "hhh-faq"
- result = db['seo_clickjobs'].insert(dic_tmp)
-
- db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/seo?charset=utf8mb4')
- #add_list = [('小坪數分割場域',0,'hhh.com.tw'),('小坪數 改造',0,'hhh.com.tw'),('小坪數格局',0,'hhh.com.tw'),('小坪數隔間',0,'hhh.com.tw'),('小坪數場域',0,'hhh.com.tw'),('小坪數場域設計',0,'hhh.com.tw'),('小坪數場域動線',0,'hhh.com.tw'),('小坪數場域規劃',0,'hhh.com.tw'),('小宅場域設計',0,'hhh.com.tw'),('小宅分割場域',0,'hhh.com.tw'),('小宅隔間',0,'hhh.com.tw')]
- while True :
- add_list = input("請輸入:")
- member=[]
- kw_string : str
- page_string : str
- ca_string : str
- check = 0
- for word in add_list:
- if word == '\'' and check == 0:
- kw_string = ""
- check = 1
- elif check == 1:
- if word == '\'':
- member.append(kw_string)
- kw_string = ""
- check = 2
- else :
- kw_string += word
- elif check == 2 :
- if word == ',':
- check =3
- page_string = ""
- elif check == 3 :
- if word ==',':
- member.append(int(page_string))
- page_string = ""
- check = 4
- else:
- page_string += word
- elif check == 4 :
- if word == '\'' :
- check = 5
- ca_string = ""
- elif check ==5:
- if word == '\'' :
- check = 0
- member.append(ca_string)
- ca_string = ""
- insert_db(member)
- member = []
- else :
- ca_string += word
|