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.1-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.1.tar.gz (7.5 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.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: arcgis_scraper-1.0.1.tar.gz
  • Upload date:
  • Size: 7.5 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.1.tar.gz
Algorithm Hash digest
SHA256 b68d59df68d57607c50e2185d7732d633e8a83dadad8af023e216e43de9f8a27
MD5 609d5875a5d27009a6058b991fe6a4c3
BLAKE2b-256 36bb118ccf87537741eec0f72f2dfbdaf6911bb43640763d6eaa378dbcf4c65b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: arcgis_scraper-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.7 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a45770e494091e97e238056b6d11812a2521366319d7440b95f769b820b439ce
MD5 bbf027833e799696aa09df3bde17da0c
BLAKE2b-256 8703ad7ad8be2563b888ec25cffb152b49b4e4b01c9ec4ff1a90cd67143fff2d

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