Skip to content

Instantly share code, notes, and snippets.

View salgo60's full-sized avatar
😴

Magnus Sälgö salgo60

😴
View GitHub Profile
@salgo60
salgo60 / Församling.query
Last active December 3, 2018 01:21
SPARQL Wikidata
# visar församlingskartor om efter 2008
OPTIONAL{ ?item wdt:P571 ?StartD .}
OPTIONAL{ ?item wdt:P576 ?SlutD .}
BIND(IF((!BOUND(?SlutD) || ?SlutD > "2008-01-01T00:00:00Z"^^xsd:dateTime ) ,
URI(CONCAT("http://geodata.scb.se/reginawebmap/main/webapp/?typ=forsamling&f=",?SCBid)),?SCBid) AS ?SCB).
@salgo60
salgo60 / Swepub.py
Created February 23, 2019 10:19
Swepub Python
from SPARQLWrapper import SPARQLWrapper, JSON
sparql = SPARQLWrapper("http://virhp07.libris.kb.se/sparql/")
sparql.setQuery("""
PREFIX bmc: <http://swepub.kb.se/bibliometric/model#>
PREFIX swpa_m: <http://swepub.kb.se/SwePubAnalysis/model#>
PREFIX mods_m: <http://swepub.kb.se/mods/model#>
PREFIX outt_m: <http://swepub.kb.se/SwePubAnalysis/OutputTypes/model#>
PREFIX xlink: <http://www.w3.org/1999/xlink#>
@salgo60
salgo60 / Karolinska playlist youtube
Created February 25, 2019 12:13
Extrahera youtube film id och person namn för att ladda till Wikidata
"""Extract the yuotube id and the title from a youtube playlist"""
from bs4 import BeautifulSoup
import requests
import urllib
import urllib.parse as urlparse
youtubePlaylist = "https://www.youtube.com/playlist?list=PL072ED1B5CB4BBFCD"
def clean_title(title):
cleaned_title = title.replace("People at KI: ","").replace("Professor of ","").replace("Möt ","").replace("Professor ","")
@salgo60
salgo60 / KiProff.py
Created February 26, 2019 19:29
Extract professors from KI using BeautifulSoup
"""Extract Professors at KI"""
from bs4 import BeautifulSoup
import requests
ki_url = "https://ki.se/en/research/professors-at-ki"
def get_ki_prof(url):
source_code = requests.get(url).text
soup = BeautifulSoup(source_code, 'html.parser')
{
"@context": "http://iiif.io/api/presentation/2/context.json",
"@id": "http://a7abb044-4f83-4ebd-a4af-4719d0b243cc",
"@type": "sc:Manifest",
"label": "[Click to edit label]",
"metadata": [],
"description": [
{
"@value": "[Click to edit description]",
"@language": "en"
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","benchmarkIndex":736},"lighthouseVersion":"4.0.0","fetchTime":"2019-04-23T10:06:14.857Z","requestedUrl":"https://sfd2019.se/forelasning-lordag-24-augusti/","finalUrl":"https://sfd2019.se/forelasning-lordag-24-augusti/","runWarnings":[],"runtimeError":{"code":"NO_ERROR","message":""},"audits":{"is-on-https":{"id":"is-on-https","title":"Uses HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, and is a prer
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","benchmarkIndex":738},"lighthouseVersion":"4.0.0","fetchTime":"2019-04-24T09:02:18.742Z","requestedUrl":"https://libris.kb.se/katalogisering/0xbfkjzj49vj3dw","finalUrl":"https://libris.kb.se/katalogisering/0xbfkjzj49vj3dw","runWarnings":[],"runtimeError":{"code":"NO_ERROR","message":""},"audits":{"is-on-https":{"id":"is-on-https","title":"Uses HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, and is a
{"userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","environment":{"networkUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","hostUserAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36","benchmarkIndex":738},"lighthouseVersion":"4.0.0","fetchTime":"2019-04-24T09:02:18.742Z","requestedUrl":"https://libris.kb.se/katalogisering/0xbfkjzj49vj3dw","finalUrl":"https://libris.kb.se/katalogisering/0xbfkjzj49vj3dw","runWarnings":[],"runtimeError":{"code":"NO_ERROR","message":""},"audits":{"is-on-https":{"id":"is-on-https","title":"Uses HTTPS","description":"All sites should be protected with HTTPS, even ones that don't handle sensitive data. HTTPS prevents intruders from tampering with or passively listening in on the communications between your app and your users, and is a
Haiku = ["Snow in my shoe","Abandoned","parrow's nest"]
currLine = 0
def printLine():
global currLine
print (Haiku[currLine])
currLine += 1
if currLine < len(Haku):
return True