|
@@ -1,3 +1,4 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
from selenium.webdriver.common.by import By
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
from selenium.webdriver.support.ui import WebDriverWait
|
|
@@ -51,7 +52,7 @@ class ArticleGenerator:
|
|
|
new_created = driver.find_element(By.XPATH, '/html/body/labs-tailwind-root/div/welcome-page/div/div[2]/div[1]/div/button/span[2]')
|
|
|
new_created.click()
|
|
|
time.sleep(2)
|
|
|
-
|
|
|
+
|
|
|
# # 點擊 專案
|
|
|
# notebooks = driver.find_element(By.CLASS_NAME, 'project-buttons-flow ng-star-inserted')
|
|
|
# # 選取第一個 project
|
|
@@ -68,16 +69,20 @@ class ArticleGenerator:
|
|
|
time.sleep(5)
|
|
|
if i == 0:
|
|
|
上傳來源 = driver.find_element(By.CSS_SELECTOR, '.mat-icon.notranslate.upload-icon.google-symbols.mat-icon-no-color')
|
|
|
+ driver.execute_script("arguments[0].scrollIntoView(true);", 上傳來源)
|
|
|
while not 上傳來源:
|
|
|
time.sleep(0.1)
|
|
|
上傳來源 = driver.find_element(By.CSS_SELECTOR, '.mat-icon.notranslate.upload-icon.google-symbols.mat-icon-no-color')
|
|
|
+ driver.execute_script("arguments[0].scrollIntoView(true);", 上傳來源)
|
|
|
上傳來源.click()
|
|
|
time.sleep(3)
|
|
|
# 找網站按鈕
|
|
|
text_click = driver.find_element(By.XPATH, '//*[@id="mat-mdc-chip-2"]/span[2]/span/span[2]')
|
|
|
+ driver.execute_script("arguments[0].scrollIntoView(true);", text_click)
|
|
|
while not text_click:
|
|
|
time.sleep(0.1)
|
|
|
text_click = driver.find_element(By.XPATH, '//*[@id="mat-mdc-chip-2"]/span[2]/span/span[2]')
|
|
|
+ driver.execute_script("arguments[0].scrollIntoView(true);", text_click)
|
|
|
text_click.click()
|
|
|
time.sleep(1)
|
|
|
# 找到 textarea 並輸入網址
|
|
@@ -85,7 +90,7 @@ class ArticleGenerator:
|
|
|
while not text_click:
|
|
|
time.sleep(0.1)
|
|
|
website_input = driver.find_element(By.ID, 'mat-input-0')
|
|
|
- website_input.send_keys(urls[0])
|
|
|
+ website_input.send_keys(url)
|
|
|
website_input.send_keys(Keys.RETURN)
|
|
|
print(f'成功輸入網址: {url}')
|
|
|
time.sleep(7)
|
|
@@ -159,7 +164,7 @@ class ArticleGenerator:
|
|
|
fore_content = ''
|
|
|
while '##' not in fore_content:
|
|
|
# 輸入生成文章的 prompt
|
|
|
- complete_prompt = "1. 彙整並生成一篇以常見問題為主的專業文章(給客戶看的,最後一句「希望這篇文章能解答...」整句直接刪掉)。2. 文章必須為 MarkDown 格式。3. 在各個分類或重要段落中加入一些具體的案例或數據。4. 必須使用段落格式,不要條列式。5. 若內容不是中文,要精準翻譯成中文。6. 生成 MarkDown 的 md 檔(須包含大標題及各個段落的標題)。"
|
|
|
+ complete_prompt = "1. 彙整並生成一篇以常見問題為主的 MarkDown 格式的 專業文章(給客戶看的,最後一句「希望這篇文章能解答...」整句直接刪掉)。2. 文章必須為 MarkDown 格式,也就是必須包含#、##等等。3. 在各個分類或重要段落中加入一些具體的案例或數據。4. 必須使用段落格式,不要條列式。5. 若內容不是中文,要精準翻譯成中文。6. 生成 MarkDown 的 md 檔(須包含大標題及各個段落的標題)。"
|
|
|
try:
|
|
|
prompt_input.send_keys(complete_prompt)
|
|
|
prompt_input.send_keys(Keys.RETURN)
|
|
@@ -240,9 +245,16 @@ if __name__ == "__main__":
|
|
|
# 範例用法
|
|
|
article_generator = ArticleGenerator(user_data_dir, profile_directory)
|
|
|
urls = [
|
|
|
- "https://www.virtualhumans.org/",
|
|
|
- "https://en.wikipedia.org/wiki/Virtual_human",
|
|
|
- "https://www.d-id.com/resources/glossary/virtual-humans/"
|
|
|
+ "https://zh.wikipedia.org/zh-tw/%E8%99%9B%E6%93%AC%E4%BA%BA",
|
|
|
+ "https://www.naipo.com/Portals/1/web_tw/Knowledge_Center/Industry_Insight/IPNC_240515_1501.htm",
|
|
|
+ "https://money.udn.com/money/story/11162/8333646",
|
|
|
+ "https://gitmind.com/tw/digital-human-creator.html",
|
|
|
+ "https://support.microsoft.com/zh-tw/office/%E5%9C%A8-microsoft-teams-%E4%B8%AD%E4%BB%A5%E8%99%9B%E6%93%AC%E4%BA%BA%E5%81%B6%E7%9A%84%E5%BD%A2%E5%BC%8F%E5%8A%A0%E5%85%A5%E6%9C%83%E8%AD%B0-5384e7b7-30c7-4bcb-8065-0c9e830cc8ad",
|
|
|
+ "https://digitaldomain.com/%E8%99%9B%E6%93%AC%E4%BA%BA%E5%AF%A6%E9%A9%97%E5%AE%A4/?lang=zh-hant",
|
|
|
+ "https://www.cdri.org.tw/xcdoc/cont?xsmsid=0H270572678476094046&sid=0N149542836021459905",
|
|
|
+ "https://learn.microsoft.com/zh-tw/azure/ai-services/speech-service/text-to-speech-avatar/what-is-text-to-speech-avatar",
|
|
|
+ "https://www.xfyun.cn/services/VirtualHumans",
|
|
|
+ "https://www.bnext.com.tw/article/65449/virtual-human-subculture"
|
|
|
]
|
|
|
|
|
|
is_succesed = article_generator.generate_article(urls)
|