Commit
·
4480fef
1
Parent(s):
36fdd8b
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,2 +1,72 @@
|
|
| 1 |
-
import
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def gen(Enter):
|
| 4 |
+
import requests
|
| 5 |
+
import time
|
| 6 |
+
import html
|
| 7 |
+
import os
|
| 8 |
+
from bs4 import BeautifulSoup as bs
|
| 9 |
+
#enter=input('enter')
|
| 10 |
+
key = Enter #input('Enter keyword here: ')
|
| 11 |
+
wrd = key.replace(' ','+')
|
| 12 |
+
url1= 'https://freeseoarticles.com/articles/go.php?keyword='+wrd+'&lang=us&rewrite=original&numbers=3&accesskey=&submit=Submit'
|
| 13 |
+
url = 'http://articlecreator.fullcontentrss.com/go.php?keyword='+wrd+'&lang=us&rewrite=original&numbers=3&accesskey=&submit=Submit'
|
| 14 |
+
resp = requests.get(url1)
|
| 15 |
+
print('Scraping Articles...')
|
| 16 |
+
time.sleep(3)
|
| 17 |
+
|
| 18 |
+
soup = bs(resp.text,'html.parser')
|
| 19 |
+
for script in soup(["script", "style",'center']):
|
| 20 |
+
script.extract()
|
| 21 |
+
text = soup.body
|
| 22 |
+
s = str(text)
|
| 23 |
+
print('Paraphasing Articles...')
|
| 24 |
+
def compactSpaces(s):
|
| 25 |
+
os = ""
|
| 26 |
+
for c in s:
|
| 27 |
+
if c != " " or (os and os[-1] != " "):
|
| 28 |
+
os += c
|
| 29 |
+
return os
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
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'}
|
| 33 |
+
|
| 34 |
+
url = 'http://freeparaphaser.ml/api.php'
|
| 35 |
+
api_key = 'cf25393bc0d3332c2e8f431b9b23661c'
|
| 36 |
+
#'16e8de6708e11f8efe3189c605c54eb1'
|
| 37 |
+
article = compactSpaces(s)
|
| 38 |
+
#article = ('how are you doing these days my dear friend')
|
| 39 |
+
lang = 'en'
|
| 40 |
+
r = requests.post(url,data={'api_key':api_key,'article':article,'lang':lang},headers=headers)
|
| 41 |
+
#print('\nParaphased Text:\n')
|
| 42 |
+
text = html.unescape(r.text)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
substr = "<h3"
|
| 48 |
+
substr1 = "</h3"
|
| 49 |
+
i1 = "<h1"
|
| 50 |
+
i2 = "<h2"
|
| 51 |
+
i3 = "</h1"
|
| 52 |
+
i4 = "</h2"
|
| 53 |
+
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')
|
| 54 |
+
#print(r,'*'*70)
|
| 55 |
+
|
| 56 |
+
id1 = r.index(i1)
|
| 57 |
+
id2 = r.index(i2)
|
| 58 |
+
id3 = r.index('<h3>')
|
| 59 |
+
ida = r.index('<br/>')
|
| 60 |
+
ida1 = r.index('<div align=')
|
| 61 |
+
|
| 62 |
+
art1 = r[id1 + len(i1)-3: ida]
|
| 63 |
+
art2 = r[id2 + len(i2)-3: id3]
|
| 64 |
+
art3 = r[id3 + len(substr)-3: ida1]
|
| 65 |
+
return art1,art2,art3
|
| 66 |
+
|
| 67 |
+
title_ = "Unique Article Generator"
|
| 68 |
+
description_ = 'Enter one or more keywords and it will generate three articles(100% UNIQUE) for you 🤓.\n\nInstagram: https://instagram.com/ims_eldrith'
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
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')
|
| 72 |
+
d.launch()
|