Skip to main content

pyreferrer

This repository is no longer maintained. It has been archived and receives no updates or security fixes.

pyreferrer is a Python package that analyzes and classifies different kinds of referrer URLs (search, social, ...).

Installing

pip install pyreferrer

Quick Start

Use Referrer.parse(referrer) to return metadata about the referrer plus a parsed url.

from pyreferrer import Referrer

# social example
referrer = 'https://twitter.com/snormore/status/524524090938245120'
print Referrer.parse(referrer)
"""
{'domain': 'twitter',
 'label': 'Twitter',
 'path': '/snormore/status/524524090938245120',
 'query': '',
 'subdomain': '',
 'tld': 'com',
 'type': 'social',
 'url': 'https://twitter.com/snormore/status/524524090938245120'
}
"""

If referrer is a search engine results page, PyReferrer will try to extract the query term from the path, based on the domain.

# search example
referrer = 'http://www.bing.com/search?q=test&go=Submit&qs=n&form=QBLH&pq=test&sc=9-4'
print Referrer.parse(referrer)
"""
{'domain': 'bing',
 'label': 'Bing',
 'path': '/search',
 'query': 'test',
 'subdomain': 'www',
 'tld': 'com',
 'type': 'search',
 'url': 'http://www.bing.com/search?q=test&go=Submit&qs=n&form=QBLH&pq=test&sc=9-4'}
 """

Often when clicking a link in a mobile app, the app will load another app and we lose the referrer information. In some cases, the app will use a shell of a browser, and include information in the user agent. By passing in the (optional) user-agent, we can extract the referrer again.

 # social user agent example
referrer = ''
user_agent_from_pinterest_app = 'Mozilla/5.0 (iPhone; CPU iPhone OS 7_0_4 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/11B554a [Pinterest/iOS]'
print Referrer.parse(referrer, user_agent=user_agent_from_pinterest_app)
"""
{'domain': 'pinterest',
 'label': 'Pinterest',
 'path': '',
 'query': '',
 'subdomain': '',
 'tld': 'com',
 'type': 'social',
 'url': 'pinterest://pinterest.com'}
 """

Contributing

To contribute, please fork the repository and add the features/data you want. After merging a submitted pull request, we will deploy the package to PyPI.

Most of the metadata is controlled by the file `pyreferrer/data/referrers.json'. Additions to this are appreciated the most, as the entire community benefits.

Metadata

Release files for pyreferrer 0.6.7

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

Source distribution (sdist)

Source distribution for pyreferrer 0.6.7
File Size Uploaded Provenance Actions
pyreferrer-0.6.7.tar.gz 21.9 kB Without provenance Details for pyreferrer-0.6.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pyreferrer 0.6.7
File Interpreter ABI Platform Actions
pyreferrer-0.6.7-py3-none-any.whl Python 3 none any Details for pyreferrer-0.6.7-py3-none-any.whl

Total release size: 43.9 kB

Release files / pyreferrer-0.6.7.tar.gz

Download URL pyreferrer-0.6.7.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b67e19effa82b3957d57c882115bac640ea55565a427334f30b2ad749e11014f
BLAKE2b-256 checksum
How to use checksums
e5e17d61414513dc8ebba1be82b4972ec06a8e9dcb07e2fa35dea5b24951ed2b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

Release files / pyreferrer-0.6.7-py3-none-any.whl

Download URL pyreferrer-0.6.7-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9d86027cf324d10bd2eb4463988d64a72d299bc69383810cc0e018e7ec3e88da
BLAKE2b-256 checksum
How to use checksums
79f571728ea9d34e55fcb096326ea35476ad057242988040f44d6b5e05656642
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.8

Security for pyreferrer 0.6.7

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.6.7 This release

2 release files No provenance

0.6.2

0.0.1

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