npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

polisens-handelser

v2.0.0

Published

Scrapes Polisen.se and retrieves the newly reported incidents

Downloads

7

Readme

Polisens Händelser

Swedish Police repeatedly upload reports on their website of what they are doing and what has happened during the day. Unfortunately their website is badly written and lacks any innovative features so reading their reports is boring and not very userfriendly. The year is 2017 and no API from the Swedish Police is available to use either.

This little nodejs tool will scrape polisen.se and retrieve all the latest reported incidents from there.

Installation

npm install polisens-handelser

Usage

const polisen = require('polisens-handelser');

polisen.getIncidents({ amount: 1 })
    .then((incidents) => console.log(incidents))
    .catch((err) => console.log(err));

Above will generate something like this in your console:

[ { unixDate: 1492001640000,
    date: '2017-04-12 14:54',
    link: '/Aktuellt/Handelser/Dalarna/2017-04-12-1454-Morddrap-Borlange/',
    type: 'Mord/dråp',
    typeInfo: undefined,
    city: 'Borlänge',
    shortBody: 'På eftermiddagen den 8 april inledde polisen i Dalarna en förundersökning angående mord. ',
    body:
     { text: 'Brottsplatsen är en bostad i området Jakobsgårdarna i Borlänge. Bostaden spärrades av i väntan på kriminalteknisk
undersökning.Den kriminaltekniska undersökningen påbörjades på kvällen den 8 april. I bostaden anträffade kriminalteknikerna tre
 avlidna personer. Rättsläkare tillkalldes under söndagen den 9 april och kropparna fördes till rättsmedicin i Uppsala, där unde
rsökning påbörjades under tisdagen den 11 april.Den 12 april inkom till Polismyndigheten ett preliminärt obduktionsbesked som an
gav att ”det inte framkommit något vid undersökningen som talar för att döden varit en följd av annans vållande.” Kompletterande
 undersökningar pågår.Närmast anhöriga är underrättade. I övrigt kommer förundersökningsledaren inte att lämna några ytterligar
kommentarer på grund av förundersökningssekretess.',
       html: '\r\n\t<p>Brottsplatsen &#xE4;r en bostad i omr&#xE5;det Jakobsg&#xE5;rdarna i Borl&#xE4;nge. Bostaden sp&#xE4;rrad
es av i v&#xE4;ntan p&#xE5; kriminalteknisk unders&#xF6;kning.</p>\r\n<p>Den kriminaltekniska unders&#xF6;kningen p&#xE5;b&#xF6;
rjades p&#xE5; kv&#xE4;llen den 8 april. I bostaden antr&#xE4;ffade kriminalteknikerna tre avlidna personer. </p>\r\n<p>R&#xE4;t
tsl&#xE4;kare tillkalldes under s&#xF6;ndagen den 9 april och kropparna f&#xF6;rdes till r&#xE4;ttsmedicin i Uppsala, d&#xE4;r u
nders&#xF6;kning p&#xE5;b&#xF6;rjades under tisdagen den 11 april.</p>\r\n<p>Den 12 april inkom till Polismyndigheten ett prelim
in&#xE4;rt obduktionsbesked som angav att &#x201D;det inte framkommit n&#xE5;got vid unders&#xF6;kningen som talar f&#xF6;r att
d&#xF6;den varit en f&#xF6;ljd av annans v&#xE5;llande.&#x201D; Kompletterande unders&#xF6;kningar p&#xE5;g&#xE5;r.</p>\r\n<p>N&
#xE4;rmast anh&#xF6;riga &#xE4;r underr&#xE4;ttade.<br>&#xA0;<br>I &#xF6;vrigt kommer f&#xF6;runders&#xF6;kningsledaren inte att
 l&#xE4;mna n&#xE5;gra ytterligar kommentarer p&#xE5; grund av f&#xF6;runders&#xF6;kningssekretess.<br></p>\r\n' } } ]

The method getIncidents is the method always to be used. This method takes options in the form of an object with several properties.

Available Options

  • amount: (number) Defaults to 10. Amount of incidents to fetch ( Max is 200, however fetching 200 with the details option set to true will get your IP temporary blocked from visiting polisen.se. I would recommend never getting more than 50 at a time because of the extensive amount of HTTP-requests made in such a short amount of time. )

  • sort: (string) Available options "desc" and "asc". Defaults to "asc"

  • details: (boolean) Defaults to true. Fetches details for every incident, otherwise only a brief description will be available for every incident.

  • area: (string) Only shows incidents from the specified area. Available options:

    • Stockholm
    • Blekinge
    • Dalarna
    • Gotland
    • Gävleborg
    • Halland
    • Jämtland
    • Jönköping
    • Kalmar
    • Krononberg
    • Norrbotten
    • Skåne
    • Södermanland
    • Uppsala
    • Värmland
    • Västerbotten
    • Västernorrland
    • Västmanland
    • Västra Götaland
    • Örebro
    • Östergötland
  • hideInfo: (boolean) Defaults to true. Hide information messages (e.g. Information om Polisens pressnummer)

  • hideSummaries (boolean) Defaults to true. Hides summaries.

  • onlyShowSummaries (boolean) Defaults to false. Will exclude all incidents except summaries.

License

MIT