Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -114,7 +114,9 @@ def scrap_portal(query):
|
|
114 |
api_key = 'AIzaSyDJUWVZG2oHkHSsYoqdqgUZwQC2Aa2kSok'
|
115 |
search_engine_id = 'a0dc878459ceb4811'
|
116 |
num_pages = 5
|
|
|
117 |
link = []
|
|
|
118 |
|
119 |
for page in range(num_pages):
|
120 |
start_index = page * 10 + 1
|
@@ -218,6 +220,7 @@ def scrap_artikel(source_type,source,models,api_key,azure_api_base):
|
|
218 |
|
219 |
|
220 |
if source_type == "input topic":
|
|
|
221 |
link = scrap_portal(source)
|
222 |
for url in link:
|
223 |
if cek_url(url):
|
@@ -235,19 +238,18 @@ def scrap_artikel(source_type,source,models,api_key,azure_api_base):
|
|
235 |
soup_html = BeautifulSoup(raw_html, "html.parser")
|
236 |
containers = soup_html.findAll('p')
|
237 |
|
238 |
-
artikel =[]
|
239 |
for paragraph in containers:
|
240 |
artic=paragraph.get_text()
|
241 |
artikel.append(artic)
|
242 |
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
|
252 |
else:
|
253 |
wd.get(source)
|
@@ -703,7 +705,7 @@ with gr.Blocks(theme = "soft", title="Wordpress Article Generator") as article_g
|
|
703 |
with gr.Row():
|
704 |
with gr.Column():
|
705 |
source_type = gr.Radio(["input link", "input topic"], label="Source")
|
706 |
-
source = gr.Textbox(placeholder="Masukkan Source Link/Topik Artikel Yang Akan Digenerate", show_label=False)
|
707 |
backlink = gr.Textbox(placeholder="Masukkan Backlink Yang Akan Diterapkan", label="Backlink")
|
708 |
keyword = gr.Textbox(placeholder="Masukkan Keyword Artikel", label="Keyword")
|
709 |
versi = gr.Radio(["openai", "azure"], label="Request Schema", info="Pilih Skema Untuk Request ke ChatGPT ")
|
|
|
114 |
api_key = 'AIzaSyDJUWVZG2oHkHSsYoqdqgUZwQC2Aa2kSok'
|
115 |
search_engine_id = 'a0dc878459ceb4811'
|
116 |
num_pages = 5
|
117 |
+
type = random.choice([' articles',' news',' trends',' technologies', ' future'])
|
118 |
link = []
|
119 |
+
query = query + type
|
120 |
|
121 |
for page in range(num_pages):
|
122 |
start_index = page * 10 + 1
|
|
|
220 |
|
221 |
|
222 |
if source_type == "input topic":
|
223 |
+
artikel =[]
|
224 |
link = scrap_portal(source)
|
225 |
for url in link:
|
226 |
if cek_url(url):
|
|
|
238 |
soup_html = BeautifulSoup(raw_html, "html.parser")
|
239 |
containers = soup_html.findAll('p')
|
240 |
|
|
|
241 |
for paragraph in containers:
|
242 |
artic=paragraph.get_text()
|
243 |
artikel.append(artic)
|
244 |
|
245 |
+
paragraf = ' '.join(artikel)
|
246 |
+
if len(paragraf)>= 18000:
|
247 |
+
part1, part2, part3, part4 = split_article(paragraf)
|
248 |
+
artikels = [part1, part2, part3, part4]
|
249 |
+
else :
|
250 |
+
artikels = [paragraf]
|
251 |
+
title, judul, url, contents = clean_scrap(artikels,url,models,api_key,azure_api_base)
|
252 |
+
return title, judul, url, contents
|
253 |
|
254 |
else:
|
255 |
wd.get(source)
|
|
|
705 |
with gr.Row():
|
706 |
with gr.Column():
|
707 |
source_type = gr.Radio(["input link", "input topic"], label="Source")
|
708 |
+
source = gr.Textbox(placeholder="Masukkan Source Berupa Link/Topik Artikel Yang Akan Digenerate", show_label=False)
|
709 |
backlink = gr.Textbox(placeholder="Masukkan Backlink Yang Akan Diterapkan", label="Backlink")
|
710 |
keyword = gr.Textbox(placeholder="Masukkan Keyword Artikel", label="Keyword")
|
711 |
versi = gr.Radio(["openai", "azure"], label="Request Schema", info="Pilih Skema Untuk Request ke ChatGPT ")
|