Vlad2012
Elite Member
- Dec 28, 2012
- 1,822
- 724
I need to generate 200 random articles based on keywords and possibly using the chatGPT API.
I tried with Zimmwriter v9.651 but unless I am mistaken it does not offer this type of function...
Do you have any suggestions that are not too expensive ?
Can this python script do the job ?
I specify that I do not want a Wordpress plugin to perform this task !
I tried with Zimmwriter v9.651 but unless I am mistaken it does not offer this type of function...
Do you have any suggestions that are not too expensive ?
Can this python script do the job ?
Code:
import openai
# Replace 'YOUR_API_KEY' with your OpenAI API key
api_key = 'YOUR_API_KEY'
# Function to create an article using keywords
def create_article(keywords):
prompt = f"Generate an article on the following topic: {', '.join(keywords)}"
response = openai.Completion.create(
engine="text-davinci-002",
prompt=prompt,
max_tokens=150, # You can adjust this limit based on the desired article length
api_key=api_key
)
return response.choices[0].text
# Main function
def main():
# Read keywords from a file (one keyword per line)
with open('keywords.txt', 'r') as file:
keywords = [line.strip() for line in file.readlines()]
# Create an article for each set of keywords
for idx, keyword_set in enumerate(keywords):
article = create_article(keyword_set)
with open(f'article_{idx+1}.txt', 'w') as article_file:
article_file.write(article)
print(f"Article {idx+1} generated successfully!")
if __name__ == "__main__":
main()
I specify that I do not want a Wordpress plugin to perform this task !
Last edited: