slight refactor

This commit is contained in:
Askill 2020-09-26 18:53:05 +02:00
parent 6d85960644
commit 6f62a3ea56
4 changed files with 13 additions and 9 deletions

View File

@ -3,7 +3,7 @@ from lxml import html
import requests
class url:
class URL:
url = "" # the url of the website to be checked
sites = dict() # dic. with all sites and urls on those sites
@ -14,8 +14,14 @@ class url:
'language' : 'English',
'User-Agent': 'Mozilla 4/0'}
exclude = {
}
exclude = [
"title=Spezial",
"doodles",
"#",
"&"
]
def __init__(self, url):
self.url = url

8
app.py
View File

@ -1,6 +1,6 @@
from flask import Flask, request, render_template
import os
import sitemapper
from URL import URL
import json
import sys
#----------------------------------------------------------------------------#
@ -11,13 +11,14 @@ app = Flask(__name__)
def graph(url):
obj = sitemapper.url(url)
obj = URL(url)
obj.run_check(url)
current = os.path.dirname(__file__)
nodes = []
drawn = []
edges = []
for key, values in obj.sites.items():
label = key.rsplit('/')[-1]
if label == "":
@ -25,14 +26,11 @@ def graph(url):
nodes.append('{' + "id: '{}', label: '{}', group: {}".format(key, label, 0) + '}')
drawn.append(key)
for key, values in obj.sites.items():
for value in values:
if value not in drawn and value not in obj.sites:
nodes.append('{' + "id: '{}', label: '{}', group: {}".format(value, value, 1) + '}')
drawn.append(value)
edges = []
for key, values in obj.sites.items():
for value in values:
edges.append('{' + "from: '{}', to: '{}'".format(key, value) + '}')

1
cached/google.de.json Normal file

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
{"nodes": ["{id: 'https://patricematz.de/', label: 'patricematz.de', group: 0}", "{id: 'https://patricematz.de/images/praktikum.pdf', label: 'praktikum.pdf', group: 0}", "{id: 'https://patricematz.de/images/bachelor.pdf', label: 'bachelor.pdf', group: 0}", "{id: 'https://github.com/Askill/Photo-Wall', label: 'https://github.com/Askill/Photo-Wall', group: 1}", "{id: 'https://www.jpmatz.de/blog.html', label: 'https://www.jpmatz.de/blog.html', group: 1}", "{id: 'https://fs.jpmatz.de', label: 'https://fs.jpmatz.de', group: 1}", "{id: 'https://github.com/Askill/mosaik', label: 'https://github.com/Askill/mosaik', group: 1}", "{id: 'https://github.com/Askill/Flask-URL-Checker', label: 'https://github.com/Askill/Flask-URL-Checker', group: 1}", "{id: 'https://github.com/Askill/UI', label: 'https://github.com/Askill/UI', group: 1}", "{id: 'https://www.linkedin.com/in/patrice-matz-b73b6814a/', label: 'https://www.linkedin.com/in/patrice-matz-b73b6814a/', group: 1}", "{id: 'https://github.com/Askill', label: 'https://github.com/Askill', group: 1}"], "edges": ["{from: 'https://patricematz.de/', to: 'https://github.com/Askill/Photo-Wall'}", "{from: 'https://patricematz.de/', to: 'https://www.jpmatz.de/blog.html'}", "{from: 'https://patricematz.de/', to: 'https://fs.jpmatz.de'}", "{from: 'https://patricematz.de/', to: 'https://github.com/Askill/mosaik'}", "{from: 'https://patricematz.de/', to: 'https://github.com/Askill/Flask-URL-Checker'}", "{from: 'https://patricematz.de/', to: 'https://github.com/Askill/UI'}", "{from: 'https://patricematz.de/', to: 'https://www.linkedin.com/in/patrice-matz-b73b6814a/'}", "{from: 'https://patricematz.de/', to: 'https://github.com/Askill'}", "{from: 'https://patricematz.de/', to: 'https://patricematz.de/images/praktikum.pdf'}", "{from: 'https://patricematz.de/', to: 'https://patricematz.de/images/bachelor.pdf'}"]}