moonlighsunligh
Elite Member
- May 1, 2010
- 2,442
- 470
which error? I posted to multiple sites with the same code.
I checked them multiple timesCheck username/password of WordPress - this is likely the cause. I has to be application password and wordpress username.
I checked them multiple times
I am using the username I use for logging in with the application password generated.
# 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 put the code you mentioned in cell #2 and this is that I got: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.
, 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 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)
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)
It's httpsI 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?
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?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.
Awesome. Just find the difference, compare wp version and php version. Are hostings different?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?
Yes, the website that doesn't work is hosted on Hostgator shared hosing plan. Same wp versionsAwesome. Just find the difference, compare wp version and php version. Are hostings different?
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
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