37 lines
795 B
Go
37 lines
795 B
Go
package scan
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/cobr-ai/apex/internal/linkedin"
|
|
)
|
|
|
|
// fetchLinkedIn opens a browser session and runs a LinkedIn job search.
|
|
// query comes from Company.ScanQuery; location defaults to empty (worldwide).
|
|
func fetchLinkedIn(ctx context.Context, query, location, company string) ([]Job, error) {
|
|
cli, err := linkedin.NewClient(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer cli.Close()
|
|
results, err := cli.SearchJobs(ctx, query, location, false)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
out := make([]Job, 0, len(results))
|
|
for _, r := range results {
|
|
c := r.Company
|
|
if c == "" {
|
|
c = company
|
|
}
|
|
out = append(out, Job{
|
|
Title: r.Title,
|
|
URL: r.URL,
|
|
Company: c,
|
|
Location: r.Location,
|
|
Source: "linkedin",
|
|
})
|
|
}
|
|
return out, nil
|
|
}
|