linkedin

package
v0.9.10 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package linkedin fetches LinkedIn user profile data via web search.

Since LinkedIn blocks direct scraping, this package uses web search engines to extract profile data from search result snippets. When a Searcher is configured, it searches for the LinkedIn URL and parses the results to extract name, headline, company, and location.

Without a Searcher configured, it returns minimal profiles with just the URL and username for manual verification.

Index

Constants

View Source
const LinkedInCacheTTL = 180 * 24 * time.Hour

LinkedInCacheTTL is the cache duration for LinkedIn profile data (180 days). LinkedIn profiles change infrequently, so long caching is appropriate.

Variables

This section is empty.

Functions

func AuthRequired

func AuthRequired() bool

AuthRequired returns true because LinkedIn requires authentication for direct access. When a Searcher is configured, we can still extract data via search results.

func LoadBraveAPIKey added in v0.9.7

func LoadBraveAPIKey() string

LoadBraveAPIKey loads the Brave API key from multiple sources (in priority order): 1. BRAVE_API_KEY environment variable 2. ~/.brave file (first line, trimmed)

Returns empty string if no key is found.

func Match

func Match(urlStr string) bool

Match returns true if the URL is a LinkedIn profile URL.

Types

type BraveOption added in v0.9.7

type BraveOption func(*BraveSearcher)

BraveOption configures a BraveSearcher.

func WithBraveCache added in v0.9.7

func WithBraveCache(cache httpcache.Cacher) BraveOption

WithBraveCache sets a cache for storing search results.

func WithBraveLogger added in v0.9.7

func WithBraveLogger(logger *slog.Logger) BraveOption

WithBraveLogger sets a logger for the searcher.

type BraveSearcher added in v0.9.7

type BraveSearcher struct {
	// contains filtered or unexported fields
}

BraveSearcher implements Searcher using the Brave Search API. Free tier: 2,000 queries/month, 1 query/second. Get an API key at https://api.search.brave.com/

func NewBraveSearcher added in v0.9.7

func NewBraveSearcher(apiKey string, opts ...BraveOption) *BraveSearcher

NewBraveSearcher creates a new Brave Search API client. apiKey is your Brave Search API subscription token.

func (*BraveSearcher) Search added in v0.9.7

func (b *BraveSearcher) Search(ctx context.Context, query string) ([]SearchResult, error)

Search performs a web search using the Brave Search API.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client handles LinkedIn requests.

func New

func New(_ context.Context, opts ...Option) (*Client, error)

New creates a LinkedIn client.

func (*Client) EnableDebug

func (*Client) EnableDebug()

EnableDebug enables debug logging (currently a no-op).

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, urlStr string) (*profile.Profile, error)

Fetch retrieves a LinkedIn profile. If a Searcher is configured, it searches for the profile URL and extracts data from the search results. Otherwise, returns a minimal profile with just the URL and username.

type Option

type Option func(*config)

Option configures a Client.

func WithBrowserCookies

func WithBrowserCookies() Option

WithBrowserCookies enables reading cookies from browser stores (currently unused - auth is broken).

func WithCookies

func WithCookies(cookies map[string]string) Option

WithCookies sets explicit cookie values (currently unused - auth is broken).

func WithHTTPCache

func WithHTTPCache(_ httpcache.Cacher) Option

WithHTTPCache sets the HTTP cache (currently unused - auth is broken).

func WithLogger

func WithLogger(logger *slog.Logger) Option

WithLogger sets a custom logger.

func WithSearcher added in v0.9.7

func WithSearcher(s Searcher) Option

WithSearcher sets a web search backend for extracting profile data. When configured, Fetch will search for the LinkedIn URL and parse the results to extract name, headline, company, and location.

type SearchResult added in v0.9.7

type SearchResult struct {
	Title   string // Page title (e.g., "Dan Lorenc - Chainguard, Inc | LinkedIn")
	URL     string // Result URL
	Snippet string // Text snippet from search results
}

SearchResult represents a single web search result.

type Searcher added in v0.9.7

type Searcher interface {
	Search(ctx context.Context, query string) ([]SearchResult, error)
}

Searcher performs web searches. Implementations should search the given query and return results. The query will be a LinkedIn profile URL.

Jump to

Keyboard shortcuts

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