Skip to main content

An ArcGIS REST API scraper

Project description

arcgis-scraper

GitHub release (latest by date) Python 3.6+ License MIT

A simple scraper to download data from ArcGIS FeatureServer and MapServer layers.

Installation

The Python module can be installed in the following ways:

Install from PyPI

pip install --upgrade arcgis-scraper

Install from wheel

If you have downloaded a .whl file from the Releases page, install it with:

pip install path/to/arcgis-scraper‑<version>‑py3‑none‑any.whl

Replace <version> with the actual version number in the filename. For example:

pip install path/to/arcgis-scraper-1.0.0-py3-none-any.whl

Install from source

git clone https://github.com/pgroenbaek/arcgis-scraper.git
pip install --upgrade ./arcgis-scraper

Usage

from arcgisscraper import ArcGISScraper

# Base URL for the ArcGIS REST services
base_url = "https://services1.arcgis.com/QcgJt0vVxSaqMKl7/arcgis/rest/services/"

# List of layers to scrape
query_urls = [
    "Adgangsveje_OD/FeatureServer/0/query",
    "Afsnitsmidter_OD/FeatureServer/0/query",
    "Basisspor_OD/FeatureServer/0/query",
]

# Initialize the scraper
scraper = ArcGISScraper(
    base_url=base_url,
    export_directory="./data",
    export_format="csv", # Options: "csv", "json", "parquet"
    max_requests_per_second=1.0,
    token=None, # Optional: token for secured services
    max_retries=3,
)

# Scrape multiple layers
scraper.scrape_layers(query_urls)

# Scrape a single layer with filtering and custom filename
scraper.scrape_layer(
    "Basisspor_OD/FeatureServer/0/query",
    filename="basisspor_filtered",
    where="SporType='Main'",
    out_fields="ID,Name,SporType"
)

Running Tests

You can run tests manually or use tox to test across multiple Python versions.

Run Tests Manually

First, install the required dependencies:

pip install pytest

Then, run tests with:

pytest

Run Tests with tox

tox allows you to test across multiple Python environments.

1. Install tox

pip install tox

2. Run Tests

tox

This will execute tests in all specified Python versions.

3. tox.ini Configuration

The tox.ini file should be in your project root:

[tox]
envlist = py36, py37, py38, py39, py310

[testenv]
deps = pytest
commands = pytest

Modify envlist to match the Python versions you want to support.

License

This Python module was created by Peter Grønbæk Andersen and is licensed under the MIT License.

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

arcgis_scraper-1.0.0.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

arcgis_scraper-1.0.0-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file arcgis_scraper-1.0.0.tar.gz.

File metadata

  • Download URL: arcgis_scraper-1.0.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for arcgis_scraper-1.0.0.tar.gz
Algorithm Hash digest
SHA256 f070dddaa1df16043c597cf279ef1b4e5cff49f1dc8c2c94000d2d097e7ff2ee
MD5 b47fedae881a61cc5f42b646e3cdfef7
BLAKE2b-256 490e22561946bb4e0dda4b55e44f104a27eec07c77f6a7286f6d72de161ed657

See more details on using hashes here.

File details

Details for the file arcgis_scraper-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: arcgis_scraper-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for arcgis_scraper-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c500feefee88f29c4e32365851b58ab9eb301bc94c2d53d8e81ade4e6cb27eea
MD5 d6da82d52d8460ebebb58a2653cdb0e3
BLAKE2b-256 f4ba99ed9dab001ac4c75838966b142d1d6e50e21163c7e817cf6d6daaea7f04

See more details on using hashes here.

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