mirror of
https://github.com/soxoj/maigret.git
synced 2026-05-07 06:24:35 +00:00
Pdf engine rewrited using xhtml2pdf
This commit is contained in:
@@ -27,3 +27,4 @@ tests/.excluded_sites
|
|||||||
|
|
||||||
# MacOS Folder Metadata File
|
# MacOS Folder Metadata File
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
/reports/
|
||||||
|
|||||||
+16
-3
@@ -3,9 +3,10 @@ from datetime import datetime
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import xmind
|
import xmind
|
||||||
|
import io
|
||||||
|
|
||||||
|
from xhtml2pdf import pisa
|
||||||
from jinja2 import Template
|
from jinja2 import Template
|
||||||
from weasyprint import HTML, CSS
|
|
||||||
|
|
||||||
import pycountry
|
import pycountry
|
||||||
|
|
||||||
@@ -177,8 +178,20 @@ def save_html_pdf_report(username_results: list, filename:str=None, filenamepdf:
|
|||||||
supposed_data=filtered_supposed_data,
|
supposed_data=filtered_supposed_data,
|
||||||
generated_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
generated_at=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
)
|
)
|
||||||
HTML(string=filled_template).write_pdf(filenamepdf, stylesheets=[CSS(filename=os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
csstext = ""
|
||||||
"resources/simple_report_pdf.css"))])
|
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)),
|
||||||
|
"resources/simple_report_pdf.css"), "r") as cssfile:
|
||||||
|
cssline = cssfile.readline()
|
||||||
|
csstext += cssline
|
||||||
|
while cssline:
|
||||||
|
cssline = cssfile.readline()
|
||||||
|
csstext += cssline
|
||||||
|
cssfile.close()
|
||||||
|
|
||||||
|
pdffile = open(filenamepdf, "w+b")
|
||||||
|
pisa.pisaDocument(io.StringIO(filled_template), dest=pdffile, default_css=csstext)
|
||||||
|
pdffile.close()
|
||||||
|
|
||||||
|
|
||||||
def save_csv_report_to_file(username: str, results: dict, csvfile):
|
def save_csv_report_to_file(username: str, results: dict, csvfile):
|
||||||
print(results)
|
print(results)
|
||||||
|
|||||||
@@ -1,123 +1,41 @@
|
|||||||
/* --------------------------------------------------------------
|
h2 {
|
||||||
|
font-size: 30px;
|
||||||
typography.css
|
width: 100%;
|
||||||
* Sets up some sensible default typography.
|
display:block;
|
||||||
|
}
|
||||||
-------------------------------------------------------------- */
|
h3 {
|
||||||
|
font-size: 25px;
|
||||||
/* Default font settings.
|
width: 100%;
|
||||||
The font-size percentage is of 16px. (0.75 * 16px = 12px) */
|
display:block;
|
||||||
html { font-size:100.01%; }
|
}
|
||||||
body {
|
h4 {
|
||||||
font-size: 75%;
|
font-size: 20px;
|
||||||
color: #222;
|
width: 100%;
|
||||||
background: #fff;
|
display:block;
|
||||||
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
}
|
||||||
|
p {
|
||||||
|
margin: 0 0 5px;
|
||||||
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Headings
|
table {
|
||||||
-------------------------------------------------------------- */
|
margin-bottom: 10px;
|
||||||
|
width:100%;
|
||||||
h1,h2,h3,h4,h5,h6 { font-weight: normal; color: #111; }
|
}
|
||||||
|
th {
|
||||||
h1 { font-size: 3em; line-height: 1; margin-bottom: 0.5em; }
|
font-weight: bold;
|
||||||
h2 { font-size: 2em; margin-bottom: 0.75em; }
|
}
|
||||||
h3 { font-size: 1.5em; line-height: 1; margin-bottom: 1em; }
|
th,td,caption {
|
||||||
h4 { font-size: 1.2em; line-height: 1.25; margin-bottom: 1.25em; }
|
padding: 4px 10px 4px 5px;
|
||||||
h5 { font-size: 1em; font-weight: bold; margin-bottom: 1.5em; }
|
}
|
||||||
h6 { font-size: 1em; font-weight: bold; }
|
table tr:nth-child(even) td,
|
||||||
|
table tr.even td {
|
||||||
h1 img, h2 img, h3 img,
|
background-color: #e5ecf9;
|
||||||
h4 img, h5 img, h6 img {
|
|
||||||
margin: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div {
|
||||||
/* Text elements
|
border-bottom-color: #3e3e3e;
|
||||||
-------------------------------------------------------------- */
|
border-bottom-width: 1px;
|
||||||
|
border-bottom-style: solid;
|
||||||
p { margin: 0 0 1.5em; }
|
|
||||||
/*
|
|
||||||
These can be used to pull an image at the start of a paragraph, so
|
|
||||||
that the text flows around it (usage: <p><img class="left">Text</p>)
|
|
||||||
*/
|
|
||||||
.left { float: left !important; }
|
|
||||||
p .left { margin: 1.5em 1.5em 1.5em 0; padding: 0; }
|
|
||||||
.right { float: right !important; }
|
|
||||||
p .right { margin: 1.5em 0 1.5em 1.5em; padding: 0; }
|
|
||||||
|
|
||||||
a:focus,
|
|
||||||
a:hover { color: #09f; }
|
|
||||||
a { color: #06c; text-decoration: underline; }
|
|
||||||
|
|
||||||
blockquote { margin: 1.5em; color: #666; font-style: italic; }
|
|
||||||
strong,dfn { font-weight: bold; }
|
|
||||||
em,dfn { font-style: italic; }
|
|
||||||
sup, sub { line-height: 0; }
|
|
||||||
|
|
||||||
abbr,
|
|
||||||
acronym { border-bottom: 1px dotted #666; }
|
|
||||||
address { margin: 0 0 1.5em; font-style: italic; }
|
|
||||||
del { color:#666; }
|
|
||||||
|
|
||||||
pre { margin: 1.5em 0; white-space: pre; }
|
|
||||||
pre,code,tt { font: 1em 'andale mono', 'lucida console', monospace; line-height: 1.5; }
|
|
||||||
|
|
||||||
|
|
||||||
/* Lists
|
|
||||||
-------------------------------------------------------------- */
|
|
||||||
|
|
||||||
li ul,
|
|
||||||
li ol { margin: 0; }
|
|
||||||
ul, ol { margin: 0 1.5em 1.5em 0; padding-left: 1.5em; }
|
|
||||||
|
|
||||||
ul { list-style-type: disc; }
|
|
||||||
ol { list-style-type: decimal; }
|
|
||||||
|
|
||||||
dl { margin: 0 0 1.5em 0; }
|
|
||||||
dl dt { font-weight: bold; }
|
|
||||||
dd { margin-left: 1.5em;}
|
|
||||||
|
|
||||||
|
|
||||||
/* Tables
|
|
||||||
-------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/*
|
|
||||||
Because of the need for padding on TH and TD, the vertical rhythm
|
|
||||||
on table cells has to be 27px, instead of the standard 18px or 36px
|
|
||||||
of other elements.
|
|
||||||
*/
|
|
||||||
table { margin-bottom: 1.4em; width:100%; }
|
|
||||||
th { font-weight: bold; }
|
|
||||||
thead th { background: #c3d9ff; }
|
|
||||||
th,td,caption { padding: 4px 10px 4px 5px; }
|
|
||||||
/*
|
|
||||||
You can zebra-stripe your tables in outdated browsers by adding
|
|
||||||
the class "even" to every other table row.
|
|
||||||
*/
|
|
||||||
tbody tr:nth-child(even) td,
|
|
||||||
tbody tr.even td {
|
|
||||||
background: #e5ecf9;
|
|
||||||
}
|
}
|
||||||
tfoot { font-style: italic; }
|
|
||||||
caption { background: #eee; }
|
|
||||||
|
|
||||||
|
|
||||||
/* Misc classes
|
|
||||||
-------------------------------------------------------------- */
|
|
||||||
|
|
||||||
.small { font-size: .8em; margin-bottom: 1.875em; line-height: 1.875em; }
|
|
||||||
.large { font-size: 1.2em; line-height: 2.5em; margin-bottom: 1.25em; }
|
|
||||||
.hide { display: none; }
|
|
||||||
|
|
||||||
.quiet { color: #b7b7b7; }
|
|
||||||
.loud { color: #000; }
|
|
||||||
.highlight { background:#ff0; }
|
|
||||||
.added { background:#060; color: #fff; }
|
|
||||||
.removed { background:#900; color: #fff; }
|
|
||||||
|
|
||||||
.first { margin-left:0; padding-left:0; }
|
|
||||||
.last { margin-right:0; padding-right:0; }
|
|
||||||
.top { margin-top:0; padding-top:0; }
|
|
||||||
.bottom { margin-bottom:0; padding-bottom:0; }
|
|
||||||
@@ -1,17 +1,9 @@
|
|||||||
<html>
|
<html>type="text/css"
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
</head>
|
</head>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no" />
|
||||||
<title>{{ username }} -- Maigret username search report</title>
|
<title>{{ username }} -- Maigret username search report</title>
|
||||||
<style>
|
|
||||||
.table td, .table th {
|
|
||||||
padding: .4rem;
|
|
||||||
}
|
|
||||||
@media print {
|
|
||||||
.pagebreak { page-break-before: always; }
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<body>
|
<body>
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row-mb">
|
<div class="row-mb">
|
||||||
@@ -22,41 +14,41 @@
|
|||||||
<small>Generated at {{ generated_at }}</small>
|
<small>Generated at {{ generated_at }}</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="">
|
<div>
|
||||||
<div class="">
|
<div>
|
||||||
<div class="">
|
<div>
|
||||||
<div class="">
|
<div>
|
||||||
<h3>Supposed personal data</h3>
|
<h3>Supposed personal data</h3>
|
||||||
{% for k, v in supposed_data.items() %}
|
{% for k, v in supposed_data.items() %}
|
||||||
<span>
|
<p>
|
||||||
{{ k }}: {{ v }}
|
{{ k }}: {{ v }}
|
||||||
</span>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% if countries_tuple_list %}
|
{% if countries_tuple_list %}
|
||||||
<span>
|
<p>
|
||||||
Geo: {% for k, v in countries_tuple_list %}{{ k }} <span class="text-muted">({{ v }})</span>{{ ", " if not loop.last }}{% endfor %}
|
Geo: {% for k, v in countries_tuple_list %}{{ k }} <span class="text-muted">({{ v }})</span>{{ ", " if not loop.last }}{% endfor %}
|
||||||
</span>
|
</p>
|
||||||
{% endif %}{% if interests_tuple_list %}
|
{% endif %}{% if interests_tuple_list %}
|
||||||
<span>
|
<p>
|
||||||
Interests: {% for k, v in interests_tuple_list %}{{ k }} <span class="text-muted">({{ v }})</span>{{ ", " if not loop.last }}{% endfor %}
|
Interests: {% for k, v in interests_tuple_list %}{{ k }} <span class="text-muted">({{ v }})</span>{{ ", " if not loop.last }}{% endfor %}
|
||||||
</span>
|
</p>
|
||||||
{% endif %}{% if first_seen %}
|
{% endif %}{% if first_seen %}
|
||||||
<span>
|
<p>
|
||||||
First seen: {{ first_seen }}
|
First seen: {{ first_seen }}
|
||||||
</span>
|
</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="">
|
<div>
|
||||||
<div class="">
|
<div>
|
||||||
<div class="">
|
<div>
|
||||||
<div class="">
|
<div>
|
||||||
<h3>Brief</h3>
|
<h3>Brief</h3>
|
||||||
<span>
|
<p>
|
||||||
{{ brief }}
|
{{ brief }}
|
||||||
</span>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -64,26 +56,37 @@
|
|||||||
{% for u, t, data in results %}
|
{% for u, t, data in results %}
|
||||||
{% for k, v in data.items() %}
|
{% for k, v in data.items() %}
|
||||||
{% if v.found and not v.is_similar %}
|
{% if v.found and not v.is_similar %}
|
||||||
<div style="clear:both;width:100%;"></div>
|
<split></split>
|
||||||
<div class="" style="margin-top:20px;padding-top:10px;border-top: 1px solid #ccc;">
|
<br/>
|
||||||
<div class="">
|
<div class="sitebox" style="margin-top: 20px;" >
|
||||||
<div class="">
|
<div>
|
||||||
<img class="" alt="Photo" style="width: 200px; height: 200px; object-fit: scale-down;float:left;" src="{{ v.status.ids_data.image or 'https://i.imgur.com/040fmbw.png' }}" data-holder-rendered="true">
|
<div>
|
||||||
<div class="" style="padding-top: 0;float:left;margin-left:50px;">
|
<table>
|
||||||
<h3 class="">
|
<tr>
|
||||||
<a class="text-dark" href="{{ v.url_main }}" target="_blank">{{ k }}</a>
|
<td style="width:201px;" >
|
||||||
</h3>
|
<img alt="Photo" style="width: 200px; height: 200px; object-fit: scale-down;" src="{{ v.status.ids_data.image or 'https://i.imgur.com/040fmbw.png' }}" data-holder-rendered="true">
|
||||||
{% if v.status.tags %}
|
</td>
|
||||||
<div class="mb-1 text-muted">Tags: {{ v.status.tags | join(', ') }}</div>
|
<td style="width:10px;" ></td>
|
||||||
{% endif %}
|
<td valign="top">
|
||||||
<p class="card-text">
|
<div class="textbox" style="padding-top: 10px;" >
|
||||||
<a href="{{ v.url_user }}" target="_blank">{{ v.url_user }}</a>
|
<h3>
|
||||||
</p>
|
<a class="text-dark" href="{{ v.url_main }}" target="_blank">{{ k }}</a>
|
||||||
|
</h3>
|
||||||
|
{% if v.status.tags %}
|
||||||
|
<div class="mb-1 text-muted">Tags: {{ v.status.tags | join(', ') }}</div>
|
||||||
|
{% endif %}
|
||||||
|
<p class="card-text">
|
||||||
|
<a href="{{ v.url_user }}" target="_blank">{{ v.url_user }}</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
{% if v.ids_data %}
|
{% if v.ids_data %}
|
||||||
</div>
|
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
<div style="width:100%">
|
<div style="width:100%">
|
||||||
<p style="background-color:#B7B7B7" ><h4>Details</h4></p>
|
<br/>
|
||||||
|
<h4>Details</h4>
|
||||||
<table class="table table-striped;" style="margin-top:5px;">
|
<table class="table table-striped;" style="margin-top:5px;">
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for k1, v1 in v.ids_data.items() %}
|
{% for k1, v1 in v.ids_data.items() %}
|
||||||
|
|||||||
+7
-20
@@ -1,52 +1,39 @@
|
|||||||
aiohttp==3.7.3
|
aiohttp==3.7.3
|
||||||
aiohttp-socks==0.5.5
|
aiohttp-socks==0.5.5
|
||||||
|
arabic-reshaper==2.1.1
|
||||||
async-timeout==3.0.1
|
async-timeout==3.0.1
|
||||||
attrs==20.3.0
|
attrs==20.3.0
|
||||||
backports.functools-lru-cache==1.6.1
|
|
||||||
beautifulsoup4==4.9.3
|
beautifulsoup4==4.9.3
|
||||||
bs4==0.0.1
|
bs4==0.0.1
|
||||||
cairocffi==1.2.0
|
|
||||||
CairoSVG==2.5.1
|
|
||||||
certifi==2020.12.5
|
certifi==2020.12.5
|
||||||
cffi==1.14.4
|
|
||||||
chardet==3.0.4
|
chardet==3.0.4
|
||||||
colorama==0.4.4
|
colorama==0.4.4
|
||||||
cssselect2==0.4.1
|
future==0.18.2
|
||||||
defusedxml==0.6.0
|
|
||||||
html5lib==1.1
|
html5lib==1.1
|
||||||
idna==2.10
|
idna==2.10
|
||||||
importlib-metadata==3.3.0
|
|
||||||
Jinja2==2.11.2
|
Jinja2==2.11.2
|
||||||
lxml==4.6.2
|
lxml==4.6.2
|
||||||
Markdown==3.3.3
|
|
||||||
MarkupSafe==1.1.1
|
MarkupSafe==1.1.1
|
||||||
mock==4.0.2
|
mock==4.0.2
|
||||||
multidict==5.1.0
|
multidict==5.1.0
|
||||||
numpy==1.19.5
|
|
||||||
pandas==1.2.0
|
|
||||||
pdf-reports==0.3.2
|
|
||||||
Pillow==8.1.0
|
Pillow==8.1.0
|
||||||
pycountry==20.7.3
|
pycountry==20.7.3
|
||||||
pycparser==2.20
|
PyPDF2==1.26.0
|
||||||
Pyphen==0.10.0
|
|
||||||
pypugjs==5.9.8
|
|
||||||
PySocks==1.7.1
|
PySocks==1.7.1
|
||||||
python-dateutil==2.8.1
|
python-bidi==0.4.2
|
||||||
python-socks==1.1.2
|
python-socks==1.1.2
|
||||||
pytz==2020.5
|
reportlab==3.5.59
|
||||||
requests==2.25.1
|
requests==2.25.1
|
||||||
requests-futures==1.0.0
|
requests-futures==1.0.0
|
||||||
six==1.15.0
|
six==1.15.0
|
||||||
socid-extractor==0.0.2
|
socid-extractor==0.0.2
|
||||||
soupsieve==2.1
|
soupsieve==2.1
|
||||||
stem==1.8.0
|
stem==1.8.0
|
||||||
tinycss2==1.1.0
|
|
||||||
torrequest==0.1.0
|
torrequest==0.1.0
|
||||||
tqdm==4.55.1
|
tqdm==4.55.0
|
||||||
typing-extensions==3.7.4.3
|
typing-extensions==3.7.4.3
|
||||||
urllib3==1.26.2
|
urllib3==1.26.2
|
||||||
WeasyPrint==52.2
|
|
||||||
webencodings==0.5.1
|
webencodings==0.5.1
|
||||||
|
xhtml2pdf==0.2.5
|
||||||
XMind==1.2.0
|
XMind==1.2.0
|
||||||
yarl==1.6.3
|
yarl==1.6.3
|
||||||
zipp==3.4.0
|
|
||||||
|
|||||||
Reference in New Issue
Block a user