• Jelajahi

    Copyright © RootSec BOT
    Best Viral Premium Blogger Templates

    Iklan

    Cara Auto Post dari ChatGPT ke WordPress dengan Google Colab

    AnonSec Team
    Desember 31, 2023, Minggu, Desember 31, 2023 WIB Last Updated 2024-03-30T15:00:49Z
    masukkan script iklan disini
    masukkan script iklan disini


    Cara Auto Post dari ChatGPT ke WordPress dengan Google Colab. Menggabungkan kemampuan Google Colab dan ChatGPT untuk menghasilkan konten yang dapat diposting secara otomatis ke WordPress adalah langkah yang cerdas dan efisien. Artikel ini akan membahas langkah-langkah tentang cara melakukan autopost dari ChatGPT ke platform WordPress menggunakan Google Colab.


    Langkah 1: Persiapan Awal


    Sebelum memulai proses autoposting, pastikan Anda memiliki hal-hal berikut:


    1. Akun WordPress: Anda harus memiliki akses ke akun WordPress, baik itu di situs WordPress.com atau WordPress self-hosted. Pastikan Anda tahu alamat situs web, username, dan password akun.


    2. Akun Google Colab: Anda memerlukan akun Google untuk mengakses Google Colab. Jika Anda belum memiliki akun, Anda perlu membuat satu.


    3. API Key dari WordPress: Untuk menghubungkan Google Colab dengan WordPress, Anda perlu menghasilkan kunci API di pengaturan akun WordPress Anda. Ini biasanya dapat ditemukan di bagian "User Profile" atau "API Keys".


    Langkah 2: Menghubungkan ke ChatGPT


    1. Buka Google Colab: Kunjungi [Google Colab](https://colab.research.google.com/) dan buat notebook baru.


    2. Import Libraries: Di dalam notebook, Anda perlu mengimpor library yang diperlukan, seperti OpenAI's `openai` untuk mengakses ChatGPT dan `wordpress_xmlrpc` untuk berkomunikasi dengan WordPress.


    3. Autentikasi ChatGPT: Gunakan kunci API ChatGPT yang dapat Anda dapatkan dari OpenAI untuk mengautentikasi akses ke ChatGPT.


    Langkah 3: Membuat Fungsi Autopost


    1. Membuat Fungsi: Buatlah fungsi di Google Colab yang menghubungkan ke ChatGPT. Fungsi ini akan menerima teks sebagai input dan menghasilkan konten yang siap diposting.


    2. Interaksi dengan ChatGPT: Gunakan fungsi yang Anda buat untuk berinteraksi dengan ChatGPT. Anda dapat mengirimkan prompt yang menjelaskan jenis konten yang ingin Anda buat.


    Langkah 4: Autoposting ke WordPress


    1. Membuat Konten: Setelah mendapatkan hasil dari ChatGPT, Anda dapat memodifikasi dan mempersiapkan konten agar sesuai dengan format posting WordPress.


    2. Menggunakan XML-RPC: Gunakan pustaka `wordpress_xmlrpc` untuk mengirimkan konten ke WordPress. Anda perlu menggunakan API key yang dihasilkan pada langkah persiapan awal.


    Langkah 5: Otomatisasi dengan Scheduling


    1. Menggunakan Task Scheduler: Jika Anda ingin autoposting terjadi secara berkala, Anda dapat menggunakan layanan seperti Google Cloud Scheduler atau layanan serupa di platform lain untuk menjalankan notebook Colab secara otomatis pada jadwal tertentu.


    2. Menyimpan Kredensial dengan Aman: Jika Anda ingin otomatisasi berkala, pastikan untuk menyimpan kredensial dengan aman dan mengenkripsi informasi sensitif.


    Dengan menggabungkan kecerdasan buatan dari ChatGPT, kemampuan komputasi awan dari Google Colab, dan kekuatan otomatisasi WordPress melalui XML-RPC, Anda dapat membuat proses autoposting yang efisien dan teratur. Langkah-langkah di atas memberikan panduan awal tentang bagaimana menghubungkan dan mengintegrasikan semua komponen ini. Dengan kreativitas dan pemahaman lebih lanjut, Anda dapat mengembangkan solusi yang lebih canggih dan personal sesuai kebutuhan Anda.


    Scipt Chatgpt to Google Colab by moonlighsunligh


    
    !pip install openai --quiet
    import openai
    import os
    openai.api_key = "isi dengan open ai key"
    
    def make_post(the_title,the_text,your_user,your_password,your_site,wordpress_category):
            import requests
            import base64
            your_credentials = your_user + ":" + your_password
            your_token = base64.b64encode(your_credentials.encode())
            your_header = {'Authorization': 'Basic ' + your_token.decode('utf-8')}
     
            api_url = your_site+'/wp-json/wp/v2/posts'
            if not wordpress_category == "":
                data = {
                    'title' : the_title,
                    'status': 'publish',
                    'content': the_text,
                    'categories': 3
                    ##'slug' : 'example-post',
                    }
            else:
                data = {
                    'title' : the_title,
                    'status': 'publish',
                    'content': the_text,
                    }
                 
            response = requests.post(api_url,headers=your_header, json=data)
            return response.json()
    
    def gpt_chat(all_params):
        the_keyword,the_prefix,the_temperature,the_max_tokens = all_params
        the_text = the_prefix + the_keyword + ":"
            #the_text =  the_prefix + the_text
        response = openai.ChatCompletion.create(
            model="gpt-3.5-turbo",
            messages=[{"role": "user", "content": the_text}],
            temperature=the_temperature,
            max_tokens=the_max_tokens
            )
     
        the_result = response["choices"][0]["message"]["content"]
     
        return the_result
    
    def fix_ahrefs_keywords(file_with_keywords):
        with open(file_with_keywords, 'r') as fyl:
            lines = fyl.readlines()
     
        good_lines = []
        for aline in lines:
            aline = aline.strip()
            if (not any(str.isdigit(x) for x in aline) or len(aline.split())>3) and not aline.strip()=="" and not "Sign up" in aline and not "N/A" in aline:
                good_lines.append(aline)
       
       
          
        with open(file_with_keywords, 'w') as f:
            for line in good_lines:
                f.write(f"{line}\n")
    
    #load file with your keywords
    file_with_keywords = "sample_data/keywords.txt"
    fix_ahrefs_keywords(file_with_keywords)
    # SETTINGS
    begin_index = 0
    end_index = 100
    your_site = "yur site url"
    your_user = "your site username"
    your_password = "isi dengan new app pasword wordpress"
    wordpress_category = "SEO" # 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()
        import time
        time.sleep(20)
        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
        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 err:
            print("we have an error",err)
            
    

    Video Tutorial auto post chatgpt to wordpress


    Komentar

    Tampilkan

    Terkini

    Tutorial

    +