on
python 워드프레스 xmlrpc를 이용한 자동포스팅 구현
python 워드프레스 xmlrpc를 이용한 자동포스팅 구현
-
좋아요
from wordpress_xmlrpc.methods import posts from wordpress_xmlrpc import * from wordpress_xmlrpc import Client, WordPressPost from wordpress_xmlrpc import WordPressTerm from wordpress_xmlrpc.methods import taxonomies from wordpress_xmlrpc.methods import media, posts client = Client("도메인/xmlrpc.php", "아이디", "비번") # set to the path to your file filename = './1.jpg' # prepare metadata data = { 'name': 'picture.jpg', 'type': 'image/jpeg', # mimetype } # read the binary file and let the XMLRPC library encode it into base64 with open(filename, 'rb') as img: data['bits'] = xmlrpc_client.Binary(img.read()) response = client.call(media.UploadFile(data)) # response == { # 'id': 6, # 'file': 'picture.jpg' # 'url': 'http://www.example.com/wp-content/uploads/2012/04/16/picture.jpg', # 'type': 'image/jpeg', # } attachment_id = response['id'] post = WordPressPost() post.title = '워드프레스 포스트 제목 z112222zzz' ## 제목 post.slug = '게시글 slug' ## slug post.content = '자동 글쓰기 내용' ## 컨텐츠 내용 post.thumbnail = attachment_id post.terms_names = { 'post_tag': 'tag,tag2,auto tag', ##게시글 태그 'category': ['test'] ## 카테고리 } post.post_status = 'publish' ##임시저장은 draft client.call(posts.NewPost(post))
카페24에서 제공하는 워드프레스 테마를 이용할경우 간혹 문제가 생기는 경우가있다.
테마 자동설치시 이 테마 쓰시는분들은 테마 자체를 수정해줘야됨
이거땜시 하루종일 했네
ㅎ ㅏ~
from http://goodclickad.tistory.com/237 by ccl(A) rewrite - 2021-10-22 10:59:05