mirror of
https://github.com/netzbegruenung/green-spider.git
synced 2024-05-02 17:14:51 +02:00
04a1e98b79
* Fix full JSON export * Update ignore list * Update README * Check for /favicon.ico and rate it as icon available * Remove broken cookies test
36 lines
889 B
Python
36 lines
889 B
Python
"""
|
|
Loads /favicon if no icon has been found otherwise
|
|
"""
|
|
|
|
import logging
|
|
from time import mktime
|
|
from datetime import datetime
|
|
from urllib.parse import urlparse
|
|
|
|
import requests
|
|
|
|
from checks.abstract_checker import AbstractChecker
|
|
|
|
class Checker(AbstractChecker):
|
|
def __init__(self, config, previous_results=None):
|
|
super().__init__(config, previous_results)
|
|
self.favicons = {}
|
|
|
|
def run(self):
|
|
for url in self.config.urls:
|
|
self.load_favicon(url)
|
|
|
|
return self.favicons
|
|
|
|
def load_favicon(self, url):
|
|
"""
|
|
This loads /favicon.ico for the site's URL
|
|
"""
|
|
parsed = urlparse(url)
|
|
ico_url = parsed.scheme + "://" + parsed.hostname + "/favicon.ico"
|
|
r = requests.head(ico_url)
|
|
if r.status_code == 200:
|
|
self.favicons[url] = {
|
|
'url': ico_url,
|
|
}
|