Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add positive URL_RULES #33

Merged
merged 1 commit into from
Dec 2, 2024
Merged

Add positive URL_RULES #33

merged 1 commit into from
Dec 2, 2024

Conversation

richardTowers
Copy link
Contributor

These are the inverse of DISALLOWED_URL_RULES - the regex must match, otherwise the request is not allowed.

This is useful if we want to crawl a small part of a particular site, where all the URLs match a particular pattern.

For example, crawling www.gov.uk/government/history with:

SITE=https://www.gov.uk/government/history URL_RULES='https://www.gov.uk/government/history' go run ./cmd

Gives:

www.gov.uk/government/history
├── 1-horse-guards-road.html
├── 10-downing-street.html
├── 11-downing-street.html
├── king-charles-street.html
├── lancaster-house.html
├── past-chancellors.html
├── past-foreign-secretaries
│   ├── austen-chamberlain.html
│   ├── charles-fox.html
│   ├── edward-grey.html
│   ├── edward-wood.html
│   ├── george-curzon.html
│   ├── george-gordon.html
│   ├── george-gower.html
│   ├── henry-petty-fitzmaurice.html
│   ├── robert-cecil.html
│   └── william-grenville.html
├── past-foreign-secretaries.html
├── past-prime-ministers
│   ├── alec-douglas-home.html
│   ├── andrew-bonar-law.html
│   ├── anthony-eden.html
│   ├── archibald-primrose-5th-earl-of-rosebery.html
│   ├── arthur-james-balfour.html
│   ├── arthur-wellesley-1st-duke-of-wellington.html
│   ├── augustus-henry-fitzroy-3rd-duke-of-grafton.html
│   ├── benjamin-disraeli-the-earl-of-beaconsfield.html
│   ├── charles-grey-2nd-earl-grey.html
│   ├── charles-watson-wentworth-2nd-marquess-of-rockingham.html
│   ├── clement-attlee.html
│   ├── david-cameron.html
│   ├── david-lloyd-george.html
│   ├── edward-heath.html
│   ├── edward-smith-stanley-14th-earl-of-derby.html
│   ├── frederick-north.html
│   ├── frederick-robinson-viscount-goderich.html
│   ├── george-canning.html
│   ├── george-grenville.html
│   ├── george-hamilton-gordon-earl-of-aberdeen.html
│   ├── gordon-brown.html
│   ├── harold-macmillan.html
│   ├── harold-wilson.html
│   ├── henry-addington-1st-viscount-sidmouth.html
│   ├── henry-campbell-bannerman.html
│   ├── henry-john-temple-3rd-viscount-palmerston.html
│   ├── henry-pelham.html
│   ├── herbert-henry-asquith.html
│   ├── james-callaghan.html
│   ├── james-ramsay-macdonald.html
│   ├── john-major.html
│   ├── john-stuart-3rd-earl-of-bute.html
│   ├── lord-john-russell-1st-earl-russell.html
│   ├── margaret-thatcher.html
│   ├── neville-chamberlain.html
│   ├── robert-banks-jenkinson-earl-of-liverpool.html
│   ├── robert-gascoyne-cecil.html
│   ├── robert-peel-2nd-baronet.html
│   ├── robert-walpole.html
│   ├── spencer-compton-1st-earl-of-wilmington.html
│   ├── spencer-perceval.html
│   ├── stanley-baldwin.html
│   ├── theresa-may.html
│   ├── thomas-pelham-holles-1st-duke-of-newcastle.html
│   ├── tony-blair.html
│   ├── william-bentinck-duke-of-portland.html
│   ├── william-cavendish-duke-of-devonshire.html
│   ├── william-ewart-gladstone.html
│   ├── william-lamb-2nd-viscount-melbourne.html
│   ├── william-petty-2nd-earl-of-shelburne.html
│   ├── william-pitt-1st-earl-of-chatham.html
│   ├── william-pitt.html
│   ├── william-wyndham-grenville-1st-baron-grenville.html
│   └── winston-churchill.html
└── past-prime-ministers.html

3 directories, 72 files

These are the inverse of DISALLOWED_URL_RULES - the regex must match,
otherwise the request is not allowed.

This is useful if we want to crawl a small part of a particular site,
where all the URLs match a particular pattern.

For example, crawling www.gov.uk/government/history with:

    SITE=https://www.gov.uk/government/history URL_RULES='https://www.gov.uk/government/history' go run ./cmd

Gives:

    www.gov.uk/government/history
    ├── 1-horse-guards-road.html
    ├── 10-downing-street.html
    ├── 11-downing-street.html
    ├── king-charles-street.html
    ├── lancaster-house.html
    ├── past-chancellors.html
    ├── past-foreign-secretaries
    │   ├── austen-chamberlain.html
    │   ├── charles-fox.html
    │   ├── edward-grey.html
    │   ├── edward-wood.html
    │   ├── george-curzon.html
    │   ├── george-gordon.html
    │   ├── george-gower.html
    │   ├── henry-petty-fitzmaurice.html
    │   ├── robert-cecil.html
    │   └── william-grenville.html
    ├── past-foreign-secretaries.html
    ├── past-prime-ministers
    │   ├── alec-douglas-home.html
    │   ├── andrew-bonar-law.html
    │   ├── anthony-eden.html
    │   ├── archibald-primrose-5th-earl-of-rosebery.html
    │   ├── arthur-james-balfour.html
    │   ├── arthur-wellesley-1st-duke-of-wellington.html
    │   ├── augustus-henry-fitzroy-3rd-duke-of-grafton.html
    │   ├── benjamin-disraeli-the-earl-of-beaconsfield.html
    │   ├── charles-grey-2nd-earl-grey.html
    │   ├── charles-watson-wentworth-2nd-marquess-of-rockingham.html
    │   ├── clement-attlee.html
    │   ├── david-cameron.html
    │   ├── david-lloyd-george.html
    │   ├── edward-heath.html
    │   ├── edward-smith-stanley-14th-earl-of-derby.html
    │   ├── frederick-north.html
    │   ├── frederick-robinson-viscount-goderich.html
    │   ├── george-canning.html
    │   ├── george-grenville.html
    │   ├── george-hamilton-gordon-earl-of-aberdeen.html
    │   ├── gordon-brown.html
    │   ├── harold-macmillan.html
    │   ├── harold-wilson.html
    │   ├── henry-addington-1st-viscount-sidmouth.html
    │   ├── henry-campbell-bannerman.html
    │   ├── henry-john-temple-3rd-viscount-palmerston.html
    │   ├── henry-pelham.html
    │   ├── herbert-henry-asquith.html
    │   ├── james-callaghan.html
    │   ├── james-ramsay-macdonald.html
    │   ├── john-major.html
    │   ├── john-stuart-3rd-earl-of-bute.html
    │   ├── lord-john-russell-1st-earl-russell.html
    │   ├── margaret-thatcher.html
    │   ├── neville-chamberlain.html
    │   ├── robert-banks-jenkinson-earl-of-liverpool.html
    │   ├── robert-gascoyne-cecil.html
    │   ├── robert-peel-2nd-baronet.html
    │   ├── robert-walpole.html
    │   ├── spencer-compton-1st-earl-of-wilmington.html
    │   ├── spencer-perceval.html
    │   ├── stanley-baldwin.html
    │   ├── theresa-may.html
    │   ├── thomas-pelham-holles-1st-duke-of-newcastle.html
    │   ├── tony-blair.html
    │   ├── william-bentinck-duke-of-portland.html
    │   ├── william-cavendish-duke-of-devonshire.html
    │   ├── william-ewart-gladstone.html
    │   ├── william-lamb-2nd-viscount-melbourne.html
    │   ├── william-petty-2nd-earl-of-shelburne.html
    │   ├── william-pitt-1st-earl-of-chatham.html
    │   ├── william-pitt.html
    │   ├── william-wyndham-grenville-1st-baron-grenville.html
    │   └── winston-churchill.html
    └── past-prime-ministers.html

3 directories, 72 files
@richardTowers richardTowers merged commit b62e975 into main Dec 2, 2024
6 checks passed
@richardTowers richardTowers deleted the add-positive-url-rules branch December 2, 2024 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants