[Step-by-Step Guide] Find keywords, create and publish 150 articles to wordpress site in less than 30 minutes using GPTChat and Python/Google Colab

I checked them multiple times
I am using the username I use for logging in with the application password generated.

I retested the code and it works, i posted a few articles. The only difference is openai api key, and username/password for sites. Otherwise it must work.

So maybe openai key is the problem.

replace cell #2 with this code and let me know what does it return.

Code:
# SETTINGS
begin_index = 11
end_index = 12
your_site = "yur site url"
your_user = "your site username"
your_password = "your site application password"
wordpress_category = "" # or you can add here a category id
title_is_keyword = "yes" #cam be "yes" or "no". If yes then the title is the keyword, if no then the title is created by GPTCHAT
remove_ai_detection = "no"

#prefix = "Write an article about"
prefix = "Write a very extremelly long and detailed article about "
#load the fixed keywords
with open(file_with_keywords, 'r') as fyl:
    keywords = fyl.readlines()
keywords = [x.strip() for x in keywords]
 
#now we create posts using GPT-chat and post them to our wordpress site
for e,akeyword in enumerate(keywords):
 
    if e<begin_index or e>=end_index:continue #this makes sure we only add article from begin to end
    the_temperature = 0.7
    the_max_tokens = 2000
    all_params = akeyword,prefix,the_temperature,the_max_tokens
    print("we are writing post #",e,", using keyword:",akeyword)
    gptchat_article = gpt_chat(all_params)
    title = akeyword.title()
 
    try:
        gptchat_article_list = gptchat_article.split("\n")
        if gptchat_article_list[0].count(".")<=1 and gptchat_article_list[1].strip()=="":
            title = gptchat_article_list[0]
            gptchat_article = gptchat_article.replace(title,"").strip()
            if title_is_keyword=="yes":
                title = akeyword.title()
    except:pass
 
 
    #now we post to out wordpres site
    print("title len",len(title))
    print("gptchat_article len",len(gptchat_article))
    import traceback
    try:
        the_response = make_post(title,gptchat_article,your_user,your_password,your_site,wordpress_category)
        the_link = the_response['guid']['rendered']
        print("the_link",the_link,"word count",len(gptchat_article.split()),"the_title:",title)
    except Exception as exc:
      traceback.print_exception(exc)
 
I retested the code and it works, i posted a few articles. The only difference is openai api key, and username/password for sites. Otherwise it must work.

So maybe openai key is the problem.

replace cell #2 with this code and let me know what does it return.
I put the code you mentioned in cell #2 and this is that I got:
we are writing post # 11 , using keyword: ahrefs
title len 21
gptchat_article len 3342

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<ipython-input-7-2254ea9fc494>", line 44, in <cell line: 19>
the_response = make_post(title,gptchat_article,your_user,your_password,your_site,wordpress_category)
File "<ipython-input-6-cce51561845b>", line 29, in make_post
return response.json()
File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
, then I tried the code you provided in cell #3 (in case you told me to put it in cell #2 by mistake!) and here is what I got:
we are writing post # 11 , using keyword: ahrefs
title len 21
gptchat_article len 5687

Traceback (most recent call last):
File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 971, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<ipython-input-10-2254ea9fc494>", line 44, in <cell line: 19>
the_response = make_post(title,gptchat_article,your_user,your_password,your_site,wordpress_category)
File "<ipython-input-8-cce51561845b>", line 29, in make_post
return response.json()
File "/usr/local/lib/python3.10/dist-packages/requests/models.py", line 975, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Please note that I am using the free trial API. I can pm you with the API to try it to make sure it's working fine, if possible.

Again, thank you for taking the time to solve our problems!
 
I think api is fine, you got the articles of normal length.

Posting to your site does not work, maybe url or pass are wrong. Is your site https or http?
 
I think api is fine, you got the articles of normal length.

Posting to your site does not work, maybe url or pass are wrong. Is your site https or http?
It's https
I am putting the full url just like this:
https://example.com

I am using the user I use to log in
I use the application password without removing the spaces in between.

Do you think it might be a plugin issue ?
 
Should work, have no idea why it does not. On my wordpess 6.3 this works well.

Try another wp site if you have it.
 
Nice , it's really helpful for our newbie members here. Thank you for helping!
 
Should work, have no idea why it does not. On my wordpess 6.3 this works well.

Try another wp site if you have it.
Actually, I tired it on another wordpress site and it works like a charm! I've no idea why it doesn't work on the first one. Do you have any clues where I should search?
 
Actually, I tired it on another wordpress site and it works like a charm! I've no idea why it doesn't work on the first one. Do you have any clues where I should search?
Awesome. Just find the difference, compare wp version and php version. Are hostings different?
 
Hello Moonlighsunligh.
in your code, it will create post sequence base on keywords.txt file, i mean that, one keyword one post, if i would like to have a post with keyword A but must be include Group relevant keyword , can it be? if yes, how can i contact you for this one.
tks
 
I have followed the tutorial above and it works. But there are some drawbacks in my opinion.

1. The resulting image does not match the keyword. (Okay, this might depend on how Ainya is herself)
2. By using this method, the resulting article is difficult to break through 1000 words. Even if it could be truncated.

How to handle it? Given that chatgpt now supports the "Continue Writing" feature
 
I have followed the tutorial above and it works. But there are some drawbacks in my opinion.

1. The resulting image does not match the keyword. (Okay, this might depend on how Ainya is herself)
2. By using this method, the resulting article is difficult to break through 1000 words. Even if it could be truncated.

How to handle it? Given that chatgpt now supports the "Continue Writing" feature

1) Yes usually image is bad. But you can put it after article. For proper image you usually need to create manually, this is a good and free site: https://playgroundai.com

2) Yes, these are usually 600-800 words long. I never trie, but you can try to first create outline, (step1), and second step would be "create an article based on this outline:" (step2). Maybe you will get a longer one. In GptChat web I do get but sometimes you need to click continue. I mean in 90 percent of the cases.
 
Hello Moonlighsunligh.
in your code, it will create post sequence base on keywords.txt file, i mean that, one keyword one post, if i would like to have a post with keyword A but must be include Group relevant keyword , can it be? if yes, how can i contact you for this one.
tks

Yes, but you then have to add relevant keywords after the keyword in .txt file.
 
What a helpful guide.
Although I am interested in blogging automation, I am clueless about how to get started.
I was greatly helped by this sharing.
I appreciate your thorough explanation, dude.
 
Back
Top