Skip to main content

Social Account Detection for Python

Project description

socials

PyPI CI Documentation

Documentation | Source Code

Python library and CLI to turn URLs into structured social media profiles.

You have a list of URLs from a scrape, a CSV export, or email signatures. Some of them are social media profiles. Socials finds them and gives you structured data to work with.

:mag: Extract Pull social profiles from scraped pages or contact lists
:white_check_mark: Validate Check if URLs are recognized social profiles
:arrows_counterclockwise: Normalize Get consistent usernames from messy URL variations
:card_file_box: Categorize Group URLs by platform or entity type
:robot: Automate Batch process URL files via CLI

Installation

Note: This README documents the upcoming 1.0 release. To try it, install with pre-release support:

pip install --pre socials
# or
uv add --pre socials

Feedback welcome at GitHub Issues.

For the current stable version (0.3.x), use pip install socials and see the v0.3.0 documentation.

Quick Example

import socials

# Parse a single URL
repo = socials.parse("https://github.com/lorey/socials")
print(repo)
# GitHubRepoURL(owner='lorey', repo='socials')

print(repo.platform)
# 'github'

print(repo.owner)
# 'lorey'

# Parse multiple URLs at once
urls = ["https://github.com/lorey", "https://twitter.com/karllorey", "https://example.com"]
result = socials.parse_all(urls)

print(result.all())
# [GitHubProfileURL(username='lorey'), TwitterProfileURL(username='karllorey')]

print(result.by_platform())
# {'github': [...], 'twitter': [...]}

Why socials?

  • Structured data, not strings. You get typed Python objects with extracted fields like username, repo, or company. Not just a matched URL string.
  • Handles the edge cases. With or without www. Trailing slashes or not. Old URL formats. Mobile URLs. Socials normalizes them all.
  • Comprehensive platform coverage. 8 platforms with multiple entity types each. Profiles, repos, companies, channels. Continuously updated as platforms change their URL formats.
  • Extensible. Need to support an internal tool or a platform we don't cover? Register your own parser and it works with the same API.
  • Built for messy real-world data. Lenient by default. Unknown URLs return None instead of crashing. Strict mode available when you need validation.
  • Type-safe with IDE support. Full type hints. Autocomplete works. Catch bugs before runtime.

Features

Typed URL Objects

Each parsed URL is a typed object with platform-specific fields:

import socials

company = socials.parse("https://linkedin.com/company/acme-corp")
print(company)
# LinkedInCompanyURL(company_name='acme-corp')

print(company.platform)
# 'linkedin'

print(company.entity_type)
# 'company'

Hierarchy Navigation

Navigate from a repo to its owner, or from any URL to its root:

import socials

repo = socials.parse("https://github.com/lorey/socials")
print(repo.get_parent())
# GitHubProfileURL(username='lorey')

Batch Extraction

Parse many URLs at once and group the results:

import socials

urls = ["https://github.com/lorey", "https://twitter.com/karllorey"]
result = socials.parse_all(urls)

result.all()
# list of all parsed URLs

result.by_platform()
# {'github': [...], 'twitter': [...]}

result.by_type()
# {'profile': [...]}

Platform Filtering

Only extract what you need:

import socials

extractor = socials.Extractor(platforms=["github", "linkedin"])
print(extractor.parse("https://twitter.com/someone"))
# None

Supported Platforms

Platform Entity Types Example Fields
GitHub profile, repo username, owner, repo
Twitter/X profile username
LinkedIn profile, company username, company_name
Facebook profile username
Instagram profile username
YouTube channel channel_id, username
Email email email
Phone phone phone

Missing a platform? Open an issue or submit a PR!

CLI

The CLI lets you process URLs directly from the command line. Run it with uvx (no install needed) or install globally with pip install socials.

$ uvx socials --help

Usage: socials [OPTIONS] COMMAND [ARGS]...

 Extract social media profile URLs from a list of URLs.

╭─ Commands ───────────────────────────────────────────────────────────────────╮
│ extract   Extract social media URLs from input.                              │
│ check     Check which platform a URL belongs to.                             │
╰──────────────────────────────────────────────────────────────────────────────╯

Examples:

# Find all social links on a webpage
$ curl -s https://karllorey.com | grep -oE 'https?://[^"]+' | socials extract
linkedin	https://www.linkedin.com/in/karllorey
github	https://github.com/lorey
instagram	https://www.instagram.com/karllorey

# Check what platform a URL belongs to
$ socials check https://github.com/lorey
github

Documentation

Full docs at socials.readthedocs.io

Related

License

GNU General Public License v3

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

socials-1.0.0a1.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

socials-1.0.0a1-py3-none-any.whl (22.3 kB view details)

Uploaded Python 3

File details

Details for the file socials-1.0.0a1.tar.gz.

File metadata

  • Download URL: socials-1.0.0a1.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for socials-1.0.0a1.tar.gz
Algorithm Hash digest
SHA256 63ba9b7222acdc4cbd3d17169866445cec1144e161c92b6edce2b6b9cd34fcbb
MD5 0410e0b9cae81118902aa45807a2251c
BLAKE2b-256 254485905d53d150bb7118d71185bb95beaafc156e13ba8c45c9c7abc1322322

See more details on using hashes here.

Provenance

The following attestation bundles were made for socials-1.0.0a1.tar.gz:

Publisher: release.yml on lorey/socials

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file socials-1.0.0a1-py3-none-any.whl.

File metadata

  • Download URL: socials-1.0.0a1-py3-none-any.whl
  • Upload date:
  • Size: 22.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for socials-1.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 0d79df43d3741ed0d31ffe39a1f9c2c3c7b595131c79d4b1bb56dd6e8fd9cdee
MD5 ee564e814825c796a6422c17c0702468
BLAKE2b-256 0e721e8239c26c7b7630311f6213b62cad529a4305209443891cea2595a1a5cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for socials-1.0.0a1-py3-none-any.whl:

Publisher: release.yml on lorey/socials

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page