twarc

package module
v0.0.2024072926 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

README

twarc (Twitter Archiver)

Usage

Quit Chrome browser and make the command launch the browser with the CDP port open.

$ twitter-archive -u user -o /path/to/output.json

Alternatively, start your browser with --remote-debugging-port=9222 (any port number will do) and pass the port number to the command.

$ /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
$ twitter-archive -p 9222 -u user -o /path/to/output.json

You can also fetch search results like https://x.com/explore by passing the query string.

$ twitter-archive -q "from:user until:2010-02-01" -o /path/to/output.json

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(ctx context.Context, targetUrl string, matchRegex string, cb func(url string, body string))

Types

type Entities

type Entities struct {
	URLs     []URL     `json:"urls"`
	Media    []Media   `json:"media"`
	Hashtags []Hashtag `json:"hashtags"`
}

type Hashtag

type Hashtag struct {
	Text string `json:"text"`
}

type Media

type Media struct {
	URL           string `json:"url"`
	ExpandedURL   string `json:"expanded_url"`
	MediaURLHTTPS string `json:"media_url_https"`
}

type StartFuncParams

type StartFuncParams struct {
	Verbose  bool
	Port     int
	Duration time.Duration
	Page     string
	Query    string
}

type StartOption

type StartOption func(*StartFuncParams)

func WithPage

func WithPage(page string) StartOption

func WithPort

func WithPort(port int) StartOption

func WithQuery

func WithQuery(query string) StartOption

func WithTimeout

func WithTimeout(timeout time.Duration) StartOption

func WithVerbose

func WithVerbose(verbose bool) StartOption

type Tweet

type Tweet struct {
	ID                int64
	FullText          string `json:"full_text"`
	Lang              string `json:"lang"`
	BookmarkCount     int    `json:"bookmark_count"`
	FavoriteCount     int    `json:"favorite_count"`
	RetweetCount      int    `json:"retweet_count"`
	ReplyCount        int    `json:"reply_count"`
	ViewCount         int    `json:"view_count"`
	Source            string `json:"source"`
	InReplyToStatusID int64
	Entities          Entities `json:"entities"`
	UserID            int64
	CreatedAt         time.Time
}

Tweet represents a tweet.

func Start

func Start(startOpts ...StartOption) (tweets []*Tweet, err error)

type URL

type URL struct {
	URL         string `json:"url"`
	ExpandedURL string `json:"expanded_url"`
}

Directories

Path Synopsis
cmd
twitter-archive command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址