Skip to main content

Social Media URL Extractor

Overview

The Social Media URL Extractor is a Python module that extracts social media URLs from a given webpage. It supports multiple social media platforms and can be used both as a module in your Python projects or as a command-line tool.

Features

  • Extracts URLs for various social media platforms such as Facebook, Twitter, LinkedIn, Instagram, YouTube, Pinterest, TikTok, Reddit, Snapchat, Tumblr, Medium, GitHub, Flickr, VK, Vimeo, Dailymotion, and Quora.
  • Configurable patterns through a YAML file.
  • Can be used as a Python module or a command-line tool.
  • Optional debug mode for detailed logging.

Installation

  1. Clone the repository: git clone https://github.com/yourusername/social-media-url-extractor.git
    cd social-media-url-extractor

  2. Create and activate a virtual environment: python -m venv venv source venv/bin/activate # On Windows use venv\Scripts\activate

  3. Install the dependencies: pip install -r requirements.txt

  4. Install the package in editable mode: pip install -e .

Usage

As a Command-Line Tool Run the tool with a URL and an optional configuration file:

extract-social-media-urls https://www.example.com --config=src/social_media_url_extractor/config.yaml
Enable debug mode for detailed logging:
extract-social-media-urls https://www.example.com --config=src/social_media_url_extractor/config.yaml --debug

As a Python Module

Import the module and create an instance of SocialMediaURLExtractor:

from social_media_url_extractor import SocialMediaURLExtractor
extractor = SocialMediaURLExtractor(config_path='src/social_media_url_extractor/config.yaml')
urls = extractor.extract_urls('https://www.example.com')
for platform, links in urls.items():
    if links:
        print(f'{platform.capitalize()}:')
        for link in links:
            print(f'  - {link}')

Configuration

The URL patterns for different social media platforms are specified in a YAML configuration file. Here is an example config.yaml:

patterns:
  facebook:  
    - "https?://(www\\.)?facebook\\.com/profile\\.php\\?id=[0-9]+/?"  
    - "https?://(www\\.)?facebook\\.com/[a-zA-Z0-9_\\-\\.]+/?"  
    - "https?://(www\\.)?fb\\.com/[a-zA-Z0-9_\\-\\.]+/?"  
  twitter:  
    - "https?://(www\\.)?twitter\\.com/[a-zA-Z0-9_\\-]+/?"  
    - "https?://(www\\.)?x\\.com/[a-zA-Z0-9_\\-]+/?"  
  linkedin:  
    - "https?://(www\\.)?linkedin\\.com/in/[a-zA-Z0-9_\\-]+/?"  
    - "https?://(www\\.)?linkedin\\.com/company/[a-zA-Z0-9_\\-]+/?"  
    - "https?://(www\\.)?linkedin\\.com/school/[a-zA-Z0-9_\\-]+/?"  
  instagram:  
    - "https?://(www\\.)?instagram\\.com/[a-zA-Z0-9_\\-\\.]+/?"  
  youtube:  
    - "https?://(www\\.)?youtube\\.com/[a-zA-Z0-9_\\-]+/?"  
    - "https?://(www\\.)?youtube\\.com/c/[a-zA-Z0-9_\\-]+/?"  
    - "https?://(www\\.)?youtube\\.com/@[a-zA-Z0-9_\\-]+/?"  
  pinterest:  
    - "https?://(www\\.)?pinterest\\.com/[a-zA-Z0-9_\\-]+/?"  
    - "https?://in\\.pinterest\\.com/[a-zA-Z0-9_\\-]+/?"  
  tiktok:  
    - "https?://(www\\.)?tiktok\\.com/@[a-zA-Z0-9_\\-\\.]+/?"  
  reddit:  
    - "https?://(www\\.)?reddit\\.com/user/[a-zA-Z0-9_\\-]+/?"  
    - "https?://(www\\.)?reddit\\.com/r/[a-zA-Z0-9_\\-]+/?"  
  snapchat:  
    - "https?://(www\\.)?snapchat\\.com/add/[a-zA-Z0-9_\\-\\.]+/?"  
  tumblr:  
    - "https?://(www\\.)?[a-zA-Z0-9_\\-]+\\.tumblr\\.com/?"  
  medium:  
    - "https?://(www\\.)?medium\\.com/@[a-zA-Z0-9_\\-\\.]+/?"  
  github:  
    - "https?://(www\\.)?github\\.com/[a-zA-Z0-9_\\-\\.]+/?"  
  flickr:  
    - "https?://(www\\.)?flickr\\.com/photos/[a-zA-Z0-9_\\-]+/?"  
  vk:  
    - "https?://(www\\.)?vk\\.com/[a-zA-Z0-9_\\-]+/?"  
  vimeo:  
    - "https?://(www\\.)?vimeo\\.com/[a-zA-Z0-9_\\-]+/?"  
  dailymotion:  
    - "https?://(www\\.)?dailymotion\\.com/[a-zA-Z0-9_\\-]+/?"  
  quora:  
    - "https?://(www\\.)?quora\\.com/profile/[a-zA-Z0-9_\\-]+/?"  

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Metadata

Release files for social-media-url-extractor 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for social-media-url-extractor 0.1.1
File Size Uploaded Provenance Actions
social-media-url-extractor-0.1.1.tar.gz 4.9 kB Without provenance Details for social-media-url-extractor-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for social-media-url-extractor 0.1.1
File Interpreter ABI Platform Actions
social_media_url_extractor-0.1.1-py3-none-any.whl Python 3 none any Details for social_media_url_extractor-0.1.1-py3-none-any.whl

Total release size: 10.5 kB

Release files / social-media-url-extractor-0.1.1.tar.gz

Download URL social-media-url-extractor-0.1.1.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
1185324f670cde063ce7975f2142bc54056f57151a8182bb9b374f2b4c6d71ea
BLAKE2b-256 checksum
How to use checksums
f6942e74735f2921f350184db7d38f288557ab64bea6606a8f00e419432cffd9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.6

Release files / social_media_url_extractor-0.1.1-py3-none-any.whl

Download URL social_media_url_extractor-0.1.1-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f07b6217d679d75dd7fb2f4615a007d59f9262d2024c842509b52eb8fde242a7
BLAKE2b-256 checksum
How to use checksums
92acea9a9a2937331ecc372808e2134583d798803971ff25d5f965169103211d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.6

Security for social-media-url-extractor 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page