Spaces:
Build error
Build error
import gradio as gr | |
def gen(Enter): | |
import requests | |
import time | |
import html | |
import os | |
from bs4 import BeautifulSoup as bs | |
#enter=input('enter') | |
key = Enter #input('Enter keyword here: ') | |
wrd = key.replace(' ','+') | |
url1= 'https://freeseoarticles.com/articles/go.php?keyword='+wrd+'&lang=us&rewrite=original&numbers=3&accesskey=&submit=Submit' | |
url = 'http://articlecreator.fullcontentrss.com/go.php?keyword='+wrd+'&lang=us&rewrite=original&numbers=3&accesskey=&submit=Submit' | |
resp = requests.get(url1) | |
print('Scraping Articles...') | |
time.sleep(3) | |
soup = bs(resp.text,'html.parser') | |
for script in soup(["script", "style",'center']): | |
script.extract() | |
text = soup.body | |
s = str(text) | |
print('Paraphasing Articles...') | |
def compactSpaces(s): | |
os = "" | |
for c in s: | |
if c != " " or (os and os[-1] != " "): | |
os += c | |
return os | |
headers={'User-Agent':'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36','Content-Type':'application/x-www-form-urlencoded'} | |
url = 'http://freeparaphaser.ml/api.php' | |
api_key = 'cf25393bc0d3332c2e8f431b9b23661c' | |
#'16e8de6708e11f8efe3189c605c54eb1' | |
article = compactSpaces(s) | |
#article = ('how are you doing these days my dear friend') | |
lang = 'en' | |
r = requests.post(url,data={'api_key':api_key,'article':article,'lang':lang},headers=headers) | |
#print('\nParaphased Text:\n') | |
text = html.unescape(r.text) | |
substr = "<h3" | |
substr1 = "</h3" | |
i1 = "<h1" | |
i2 = "<h2" | |
i3 = "</h1" | |
i4 = "</h2" | |
r = text.replace(substr,i1,1).replace(substr,i2,1).replace(substr1,i3,1).replace(substr1,i4,1).replace('Png','png').replace('Jpeg','jpeg').replace('Img','img').replace('Jpg','jpg') | |
#print(r,'*'*70) | |
id1 = r.index(i1) | |
id2 = r.index(i2) | |
id3 = r.index('<h3>') | |
ida = r.index('<br/>') | |
ida1 = r.index('<div align=') | |
art1 = r[id1 + len(i1)-3: ida] | |
art2 = r[id2 + len(i2)-3: id3] | |
art3 = r[id3 + len(substr)-3: ida1] | |
return art1,art2,art3 | |
title_ = "Unique Article Generator" | |
description_ = 'Enter one or more keywords and it will generate three articles(100% UNIQUE) for you 🤓.\n\nInstagram: https://instagram.com/ims_eldrith' | |
d = gr.Interface(fn=gen,inputs=[gr.Textbox(lines=2,placeholder='Enter Keywords here...')],outputs=[gr.Textbox(label='Article: 1'),gr.Textbox(label='Article: 2'),gr.Textbox(label='Article: 3')],title=title_, description=description_,allow_flagging='never') | |
d.launch() |