Skip to main content

A classifier for detecting soft 404 pages

Project description

PyPI Version Build Status Code Coverage

A “soft” 404 page is a page that is served with 200 status, but is really a page that says that content is not available.

Installation

pip install soft-404

Usage

The easiest way is to use the soft404.probability function:

>>> import soft404
>>> soft404.probability('<h1>Page not found</h1>')
0.9736860086882132

You can also create a classifier explicitly:

>>> from soft404 import Soft404Classifier
>>> clf = Soft404Classifier()
>>> clf.predict('<h1>Page not found</h1>')
0.9736860086882132

Development

Classifier is trained on 37486 pages from 6660 domains, with 404 page ratio of about 1/3. With 10-fold cross-validation, PR AUC (average precision) is 0.990 ± 0.006, and ROC AUC is 0.994 ± 0.004.

Getting data for training

Install dev requirements:

pip install -r requirements_dev.txt

Run the crawler for a while (results will appear in pages.jl.gz file):

cd crawler
scrapy crawl spider -o pages.jl -t gzip -s JOBDIR=job

Training

First, extract text and structure from html:

./soft404/convert_to_text.py pages.jl.gz items

This will produce two files, items.meta.jl.gz and items.items.jl.gz. Next, train the classifier:

./soft404/train.py items

Vectorizer takes a while to run, but it’s result is cached (the filename where it is cached will be printed on the next run). If you are happy with results, save the classifier:

./soft404/train.py items --save soft404/clf.joblib

License

License is MIT.


define hyperiongray

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

soft-404-0.3.1.tar.gz (34.4 kB view details)

Uploaded Source

Built Distribution

soft_404-0.3.1-py2.py3-none-any.whl (34.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file soft-404-0.3.1.tar.gz.

File metadata

  • Download URL: soft-404-0.3.1.tar.gz
  • Upload date:
  • Size: 34.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7

File hashes

Hashes for soft-404-0.3.1.tar.gz
Algorithm Hash digest
SHA256 38484604c4388ba6663a2f717d59546db13e0a4ac22dc7b1f5f75210ed49d0c2
MD5 b5def9a96949efaf5b9c57e44931dcd9
BLAKE2b-256 990a7eb781f1667f47e2ee8d2b63d4c2a2b20a5807877cbfc3d02efaf29650eb

See more details on using hashes here.

File details

Details for the file soft_404-0.3.1-py2.py3-none-any.whl.

File metadata

  • Download URL: soft_404-0.3.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 34.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.7

File hashes

Hashes for soft_404-0.3.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e3b653d48e913ec85bff73020ad05e7efe9fbe41b9d6dac2c79568821e92f363
MD5 0caa2b9e27dba6e44feef4467582b0d1
BLAKE2b-256 70b9bfdaf6c3711b2ed34048b9192a786c1deb610be68017ee11b855ab7f7fea

See more details on using hashes here.

Supported by

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