Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show municipality logos in results #15

Open
joepio opened this issue Mar 25, 2019 · 4 comments
Open

Show municipality logos in results #15

joepio opened this issue Mar 25, 2019 · 4 comments
Labels
help wanted Extra attention is needed

Comments

@joepio
Copy link
Member

joepio commented Mar 25, 2019

This would make results more recognizeable and make the UI a little more colorful.

Getting the images is tricky, though. Perhaps we could use Selenium to scrape from websites (see example below, thanks to @bwbroersma, who's working on an 'allmanak' API which inlcudes municipality logos)

let data = await driver.executeScript(function() {
           return Array.from(document.querySelectorAll('svg[class*="logo"],img[class*="logo"],*[class*="logo"] svg,*[class*="logo"] img,svg[id*="logo"],img[id*="logo"],*[id*="logo"] svg,*[id*="logo"] img,a[href="/"] svg,a[href="/"] img,div[class*="logo"],div[id*="logo"],a[href="/"] div,a[href="/"]')).map(x => {if(x.tagName=="DIV" || x.tagName=="A"){s=window.getComputedStyle(x).backgroundImage;if(s){t=s.match(/url\(\s*["']?([^"']+)['"]?\s*\)/);if(t){y=t[1];}else{y=null;}}else{y=null;}} else if (x.tagName == 'svg') {y=x.outerHTML;} else if (x.tagName == 'IMG') {y=x.src} else {console.log(x.tagName);y=x;};return y;});
});
@joepio joepio added the help wanted Extra attention is needed label Mar 25, 2019
@bwbroersma
Copy link

I unwrapped that one-liner a bit ;), and put it in a project.
https://github.com/openstate/logo-finder

I will notify this issue when we publish the API.

@bwbroersma
Copy link

bwbroersma commented Mar 29, 2019

I will do a new scrape soon with background colors & more logo's (I expect 320+/355), currently there are 248 in the DB (of which one is a data uri, which I will also change to a static resource)

curl 'https://rest-api.allmanak.nl/v0/overheidsorganisatie?type=eq.Gemeente&einddatum=is.null&select=naam,ictucode,logo(url,license,backgroundcolor)' --compressed

@jorritb
Copy link

jorritb commented Jun 7, 2019

Logo and website URL are now also in the OpenState Allmanak so they could be added to the Organization ontology in ORI:

https://rest-api.allmanak.nl/v0/overheidsorganisatie?afkorting=eq.Delft&select=naam,logo(url,backgroundcolor,license),website:contact-%3Einternet

@joepio
Copy link
Member Author

joepio commented Jul 16, 2019

Related: openstate/open-raadsinformatie#180

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants