Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

An interface for fetching statistical data from BRÅ. This is not an official service!

Project Description
# BRÅ Scraper

This is a Python module for fetching statistical data about reported crime from [Brottsförbyggande rådet](http://statistik.bra.se/solwebb/action/index).

### Installation

`pip install -r requirements.txt`


### Usage

Init scraper:

```python
from bra_scraper.BRA import BRA
scraper = BRA()
```

List topics.

```python
print scraper.topics
```

Explore a topic.

```python

# Get a topic by name (or url)
topic = scraper.topic(u"Månads- och kvartalsvis - Land och län 1975-2014, land och region 2015-")

# Get available regions
print topic.regions

# Get available crimes
print topic.crimes

```

Make query.

```python
# Query date range
data = topic.query(period_start="2016-01-01", period_end="2016-06-30")

# Query by region and crimes
data = topic.query(regions=["Bjuv kommun"], crimes=[u"Våldsbrott"])

```

Save results.

```python
data.to_csv("my_data_dump.csv")
```

### Command line usage

With `run.py` you can run the scraper from the command line. Run `python run.py --help` for help:

```
-t TOPIC, --topic TOPIC
name of the topic to be scraped (from http://statistik
.bra.se/solwebb/action/start?menykatalogid=1)
-o OUTFILE, --outfile OUTFILE
store result in this file
-ps PERIOD_START, --period_start PERIOD_START
start date (for example 2016-09-01)
-pe PERIOD_END, --period_end PERIOD_END
end date (for example 2016-09-01)
```
Release History

Release History

This version
History Node

0.1.6

History Node

0.1.5

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
bra_scraper-0.1.6.tar.gz (12.3 kB) Copy SHA256 Checksum SHA256 Source Jun 2, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting