[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

Please help, when I run the code It brings error like this:
we are writing post # 1 , using keyword: skin damage from sun
we have an error Expecting value: line 1 column 1 (char 0)
we are writing post # 2 , using keyword: actinic skin damage
we have an error Expecting value: line 1 column 1 (char 0)
we are writing post # 3 , using keyword: long-term skin damage from radiation therapy
we have an error Expecting value: line 1 column 1 (char 0)
 
Is this version with images or not?

If not, for debugging write this is the second cell.


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)
 
as suggested using above code, producing this error: (previously use your code without image)

we are writing post # 1 , using keyword: skin damage from sun
title len 20
gptchat_article len 5119

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-34-fc85d47bc606>", line 44, in <cell line: 19>
the_response = make_post(title,gptchat_article,your_user,your_password,your_site,wordpress_category)
File "<ipython-input-32-5b3d629e24af>", 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)

only modifiy this line:
begin_index = 1
end_index = 2
 
as suggested using above code, producing this error: (previously use your code without image)



only modifiy this line:
Finally make it work, thank you for this guide.

the problem is this, everyone should be aware:
your password part must not contain any space so delete all space from the password.
your_password = ""
 
Finally make it work, thank you for this guide.

the problem is this, everyone should be aware:
your password part must not contain any space so delete all space from the password.

Awesome, I saw this is something related to wordpress login.

Password is something like:

Code:
your_password = "bla bla bla bla"

For you works only after you change the pass to:

Code:
your_password = "blablablabla"

?



For me it works even with spaces, removing spaces might be needed only for some wordpress installs? Which version of WP do you run?
 
Awesome. Just find the difference, compare wp version and php version. Are hostings different?
Yes, the website that doesn't work is hosted on Hostgator shared hosing plan. Same wp versions

Just wanted to say that I moved the site that wasn't working from hostgator to another host and it's working now perfectly fine!

Thanks for the help buddy!
 
Awesome, I saw this is something related to wordpress login.

Password is something like:

Code:
your_password = "bla bla bla bla"

For you works only after you change the pass to:

Code:
your_password = "blablablabla"

?



For me it works even with spaces, removing spaces might be needed only for some wordpress installs? Which version of WP do you run?
Exactly like you mentioned, without space.
My wordpress installation version is 6.3.1
 
Just wanted to say that I moved the site that wasn't working from hostgator to another host and it's working now perfectly fine!

Thanks for the help buddy!

Sure, you are welcome.

Interesting to know that hostgator does not work. Probably incoming or outgoing port (for wordpress API) is blocked or something like that. They disable many things


Exactly like you mentioned, without space.
My wordpress installation version is 6.3.1

Awesome, probably the solution for majority of people.
 
Is it possible to change the language?

Edit: i have this error

we have an error Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)




 
Last edited:
Is it possible to change the language?

Edit: i have this error

we have an error Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)





Yes, just tell it to write in XX language after the keyword. For example: how to bake a steak in French language


Error is probably related to wp login data, try without spaces in password and username should be the same as wp username.
 
Yes, just tell it to write in XX language after the keyword. For example: how to bake a steak in French language


Error is probably related to wp login data, try without spaces in password and username should be the same as wp username.

I have admin as username as I also login and the password without spaces it still comes the error:

we are writing post # 11 , using keyword: ***** we have an error Unexpected UTF-8 BOM (decode using utf-8-sig): line 1 column 1 (char 0)

Thanks fort you Help
 
You can try on another wp site on another hosting. For examples this does not work on Hostgator.
 
my wordpress is a Custom classification
example: post_type=post to post_type=news
How to modify code
 
Sure, you are welcome.

Interesting to know that hostgator does not work. Probably incoming or outgoing port (for wordpress API) is blocked or something like that. They disable many things

Awesome, probably the solution for majority of people.
Only one thing from the guide that still doesn't work for me, how to insert the post into wordpress category no matter what I do it doesn't work.

Already tried both using category name e.g: food, sports, fashion, etc and using category ID without any success.
Please help.
 
Name does not work, you should use ID. And it can be number of string, one of these have to work. String is with quotes, "1" and number without.
 
Would be awesome if someone could add support for downloading images from Pexels as well. Thanks a lot for sharing this information anyhow! Highly appreciated.
 
Back
Top