This Golang package provides long-form posting on Twitter Blue using the Playwright library.
To use this package, you need to have Go installed. You can install it using the following command:
go get github.com/username/xpostblue
# playwright
go run github.com/playwright-community/playwright-go/cmd/playwright@latest install --with-deps
# Or
go install github.com/playwright-community/playwright-go/cmd/playwright@latest
playwright install --with-deps
package main
import (
"github.com/username/x-post-to-blue"
)
func main() {
// Create a new client
client := xpostblue.New(true)
// Close the client
defer client.Close()
// Login to Twitter
err := client.Login("yourusername", "yourpassword")
if err != nil {
panic(err)
}
// Post a message on Twitter
files := []string{"./images/1.jpg", "./images/2.jpg"}
err = client.Post(true, 5, "Hello, world! and long long-text", nil)
if err != nil {
panic(err)
}
}
See module test file for details.
ClientBody
: Main client struct containing Playwright instances and page methodsPostLocator
: Locator struct containing the elements for login and post sections
New(isHeadless bool) *ClientBody
: Initialize a new clientClose()
: Close the client and browserLogin(username, password string) error
: Login to TwitterPost(isPost bool, sleepSecForUpload int, msg string, files []string) error
: Post a message on Twitter
- Playwright Go
- Zerolog
This package is released under the MIT License.
For more information on Playwright Go, visit https://github.com/mxschmitt/playwright-go.
Feel free to contribute to this package by submitting issues or pull requests on GitHub.