418 lines
14 KiB
Python
418 lines
14 KiB
Python
# -*- coding: utf-8 -*-
|
|
# flake8: noqa: E501
|
|
from __future__ import unicode_literals
|
|
|
|
import re
|
|
from datetime import date
|
|
import random
|
|
|
|
from .compat import (
|
|
compat_parse_qs as parse_qs,
|
|
compat_urllib_parse_quote as qs_quote,
|
|
compat_urllib_parse_urlparse as urlparse,
|
|
compat_str,
|
|
py_major_ver,
|
|
)
|
|
|
|
|
|
class LFiError(Exception):
|
|
pass
|
|
|
|
|
|
class FxckerError(Exception):
|
|
pass
|
|
|
|
|
|
def get_user_agent():
|
|
if bool(random.getrandbits(1)):
|
|
# Google Chrome
|
|
return ("Mozilla/5.0 ({platform}) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{version} Safari/537.36"
|
|
).format(platform=random.choice([
|
|
"Windows NT 10.0; Win64; x64",
|
|
"Windows NT 10.0; WOW64",
|
|
"Windows NT 10.0",
|
|
]), version=random.choice([
|
|
# https://en.wikipedia.org/wiki/Google_Chrome_version_history
|
|
# https://bin.ptrcnull.me/uruyewogug.js
|
|
"64.0.3282",
|
|
"65.0.3325",
|
|
"66.0.3359",
|
|
"67.0.3396",
|
|
"68.0.3440",
|
|
"69.0.3497",
|
|
"70.0.3538",
|
|
"71.0.3578",
|
|
"72.0.3626",
|
|
"73.0.3683",
|
|
"74.0.3729",
|
|
"75.0.3770",
|
|
"76.0.3809",
|
|
"77.0.3865",
|
|
"78.0.3904",
|
|
"79.0.3945",
|
|
"80.0.3987",
|
|
"81.0.4044",
|
|
"83.0.4103",
|
|
"84.0.4147",
|
|
"85.0.4183",
|
|
"86.0.4240",
|
|
"87.0",
|
|
"87.0",
|
|
]))
|
|
else:
|
|
# Mozilla Firefox
|
|
return ("Mozilla/5.0 ({platform}; rv:{version}) Gecko/20100101 Firefox/{version}"
|
|
).format(platform=random.choice([
|
|
"Windows NT 10.0; Win64; x64",
|
|
"Windows NT 10.0",
|
|
]), version=random.choice([
|
|
# https://www.mozilla.org/en-US/firefox/releases/
|
|
# https://bin.ptrcnull.me/dijaboyewi.js
|
|
"80.0",
|
|
"79.0",
|
|
"78.0",
|
|
"77.0",
|
|
"76.0",
|
|
"75.0",
|
|
"74.0",
|
|
"73.0",
|
|
"72.0",
|
|
"71.0",
|
|
"70.0",
|
|
"69.0",
|
|
"68.0",
|
|
]))
|
|
|
|
|
|
def get_email_address():
|
|
day_today = date.today().strftime('%m-%d')
|
|
if day_today in ( # "MM-DD"
|
|
'05-17', # https://en.wikipedia.org/wiki/International_Day_Against_Homophobia,_Transphobia_and_Biphobia
|
|
'09-28', # https://en.wikipedia.org/wiki/International_Safe_Abortion_Day
|
|
'11-20', # https://en.wikipedia.org/wiki/Transgender_Day_of_Remembrance
|
|
'12-10', # https://en.wikipedia.org/wiki/Human_Rights_Day
|
|
):
|
|
return random.choice((
|
|
"kontakt@stronazycia.pl",
|
|
"kontakt@petycjaonline.pl",
|
|
"gejprzeciwkoswiatu@gmail.com",
|
|
"biuro.prasowe@konfederacja.net",
|
|
"biuro@pis.org.pl",
|
|
"Zbigniew.Ziobro@sejm.pl",
|
|
"Sebastian.Kaleta@sejm.pl",
|
|
"Michal.Wojcik@sejm.pl",
|
|
"Tomasz.Rzymkowski@sejm.pl",
|
|
|
|
# LGB Alliance
|
|
"developers@lgballiance.org.uk",
|
|
"koalicjalgb@gmail.com",
|
|
"frentelgb@gmail.com",
|
|
"alianzalgb@gmail.com",
|
|
"lgsolidarnamreza@gmail.com",
|
|
"redlesbianasgaysbisexuales@gmail.com",
|
|
|
|
# Agenda Europe - https://agendaeurope.wordpress.com/links-2/
|
|
"info@acton.org",
|
|
"istitutoacton@acton.org",
|
|
"info@institutoacton.com.ar",
|
|
"kmauren@acton.org",
|
|
"sgregg@acton.org",
|
|
"kabbs@acton.org",
|
|
"tvogt@acton.org",
|
|
"sbarrows@acton.org",
|
|
"croelofs@acton.org",
|
|
"kmauren@acton.org",
|
|
"ekohn@acton.org",
|
|
"mseverance@acton.org",
|
|
"info@c-fam.org",
|
|
"Media@c-fam.org",
|
|
"Hannah@c-fam.org",
|
|
"press@citizengo.org",
|
|
"english@citizengo.org",
|
|
"admin@dialoguedynamics.com",
|
|
"ipf@ipfe.org",
|
|
"internationalipf@ipfe.org",
|
|
"ehertfelder@ipfe.org",
|
|
"donor@lifesitenews.com",
|
|
"support@lifesitenews.com",
|
|
"corrections@lifesitenews.com",
|
|
"advertising@lifesitenews.com",
|
|
"marketing@lifesitenews.com",
|
|
"submit@lifesitenews.com",
|
|
"info@od.org.au",
|
|
"finland@od.org",
|
|
"contacto@puertasabiertasal.org",
|
|
"philippines@od.org",
|
|
"info@puertasabiertas.org",
|
|
"info@opendoors.at",
|
|
"info@portesouvertes.ch",
|
|
"contact@portesouvertes.fr",
|
|
"info@opendoors.pl",
|
|
"sweden@od.org",
|
|
"sarab@od.org",
|
|
"presskontakt@od.org",
|
|
"falecom@portasabertas.org.br",
|
|
"info@opendoors.de",
|
|
"youth@opendoors.de",
|
|
"pressebuero@opendoors.de",
|
|
"info@od.org.nz",
|
|
"info@porti-deschise.org",
|
|
"info@portesouvertes.ch",
|
|
"opendoorsca@odcan.org",
|
|
"enquiryhk@od.org",
|
|
"norway@od.org",
|
|
"mortena@od.org",
|
|
"lindaa@od.org",
|
|
"southafrica@od.org",
|
|
"inspire@opendoorsuk.org",
|
|
"odireland@opendoorsuk.org",
|
|
"denmark@od.org",
|
|
"info@porteaperteitalia.org",
|
|
"cristinam@od.org",
|
|
"cristiann@od.org",
|
|
"odi-nl@od.org",
|
|
"info@fedsoc.org",
|
|
"Info@C-FAM.org",
|
|
"info@womenworldplatform.com",
|
|
"info@wcfverona.org",
|
|
"webadmin@ifamnews.com",
|
|
"info@profam.org",
|
|
"wya@wya.net",
|
|
"africa@wya.net",
|
|
"asiapacific@wya.net",
|
|
"europe@wya.net",
|
|
"latinamerica@wya.net",
|
|
"mena@wya.net",
|
|
"northamerica@wya.net",
|
|
"info@europeanrenewal.org",
|
|
"secretariat@eclj.org",
|
|
"office@ecpm.info",
|
|
"office@europeandignitywatch.org",
|
|
"info@oneofus.eu",
|
|
"info@familienforum.at",
|
|
"postbox@imabe.org",
|
|
"office@ief.at",
|
|
"office@youthforlife.net",
|
|
"office@kairos-pr.com",
|
|
"office@lebenskonferenz.at",
|
|
"info@pro-life.by",
|
|
"svabulgaria@gmail.com",
|
|
"press@uimeobitelji.net",
|
|
"cenap@cenap.cz",
|
|
"info@hnutiprozivot.cz",
|
|
"rodiny@rodiny.cz",
|
|
"oujezdska@rodiny.cz",
|
|
"charvatova@rodiny.cz",
|
|
"horakova@rodiny.cz",
|
|
"pavlisova@rodiny.cz",
|
|
"kucerova@rodiny.cz",
|
|
"jegvilleve@rettentilliv.dk",
|
|
"leder@abortlinien.dk",
|
|
"ung@rettentilliv.dk",
|
|
"web@rettentilliv.dk",
|
|
"regnskab@rettentilliv.dk",
|
|
"elukultuur@gmail.com",
|
|
"info@saptk.ee",
|
|
"presse@fondationlejeune.org",
|
|
"info@alfa-ev.de",
|
|
"berlin@bv-lebensrecht.de",
|
|
"info@cdl-online.de",
|
|
"info@datenschutz.ekd.de",
|
|
"datenschutz@ojc.de",
|
|
"kontakt@familien-schutz.de",
|
|
"info@jvl-ev.de",
|
|
"zfl@juristen-vereinigung-lebensrecht.de",
|
|
"kontakt@familie-geht-vor.de",
|
|
"info@agalia.org.gr",
|
|
"kapcsolat@egyuttazeletert.hu",
|
|
"asszonyszovetseg@asszonyszovetseg.hu",
|
|
"info@familyandlife.org",
|
|
"info@ionainstitute.ie",
|
|
"info@famigliadomani.it",
|
|
"contact@novaeterrae.eu",
|
|
"giuristiperlavita2@gmail.com",
|
|
"postmaster@giuristiperlavita.org",
|
|
"webmaster@giuristiperlavita.org",
|
|
"redazione@lanuovabq.it",
|
|
"segreteria@lanuovabq.it",
|
|
"inserzioni@lanuovabq.it",
|
|
"segreteria@lamanifpourtous.it",
|
|
"press@lamanifpourtous.it",
|
|
"info@provitaefamiglia.it",
|
|
"stampa@provitaefamiglia.it",
|
|
"redazione@provitaefamiglia.it",
|
|
"asociacijagimene@gmail.com",
|
|
"info@schwanger.li",
|
|
"beratung@schwanger.li",
|
|
"info@schwanger.li",
|
|
"af@ateitis.lt",
|
|
"info@propatria.lt",
|
|
"contact@moldovacrestina.md",
|
|
"secretariaat@provita.nl",
|
|
"info@schreeuwomleven.nl",
|
|
"morten@menneskeverd.no",
|
|
"kristin@menneskeverd.no",
|
|
"maria@menneskeverd.no",
|
|
"susanne@menneskeverd.no",
|
|
"ingrid@menneskeverd.no",
|
|
"sara@menneskeverd.no",
|
|
"fredrik@menneskeverd.no",
|
|
"bjarne@menneskeverd.no",
|
|
"ingridbs@menneskeverd.no",
|
|
"annekari@menneskeverd.no",
|
|
"post@menneskeverd.no",
|
|
"fundacja@glosdlazycia.pl",
|
|
"biuro@mamaitata.org.pl",
|
|
"biuro@ordoiuris.pl",
|
|
"rzecznik@ordoiuris.pl",
|
|
"interwencja@ordoiuris.pl",
|
|
"f.p.p.vida@gmail.com",
|
|
"office@alianta-familiilor.ro",
|
|
"asociatiadiaconia@yahoo.com",
|
|
"redactia@culturavietii.ro",
|
|
"contact@asociatiaprovita.ro",
|
|
"profamilia.ru@gmail.com",
|
|
"info@familypolicy.ru",
|
|
"info@alianciazarodinu.sk",
|
|
"donumvitaeoz@gmail.com",
|
|
"forumzivota@forumzivota.sk",
|
|
"info@zavod-zivim.si",
|
|
"info@cidevida.org",
|
|
"forofamilia@forofamilia.org",
|
|
"prensa@forofamilia.org",
|
|
"prensa@hazteoir.org",
|
|
"info@profesionalesetica.org",
|
|
"asistencia24@redmadre.es",
|
|
"info@valoresysociedad.org",
|
|
"info@respektlivet.nu",
|
|
"info@shrl.eu",
|
|
"info@starke-muetter.com",
|
|
"family_institute@ucu.edu.ua",
|
|
"info@christianconcern.com",
|
|
"press@c4m.org.uk",
|
|
"admin@c4m.org.uk",
|
|
"info@core-issues.org",
|
|
"info@righttolife.org.uk",
|
|
"information@spuc.org.uk",
|
|
"info@spucscotland.org",
|
|
"belfast@spuc.org.uk",
|
|
"info@christian.org.uk",
|
|
"info@vfjuk.org",
|
|
))
|
|
|
|
# random first name
|
|
email = random.choice((
|
|
# ok, you got me, not so much random
|
|
"laura", "dominika", "patrycja",
|
|
# bromine and barium
|
|
"andrea", "brock", "jesse", "walter", "mike", "flynn", "marie", "hank", "gustavo", "saul",
|
|
# an edgy teenager and her friends
|
|
"haruhi", "kyon", "mikuru", "yuki", "itsuki", "ryouko",
|
|
# that's totally how they live
|
|
"yuuko", "mai", "mio", "nano", "hakase", "sakamoto", "misato", "izumi", "yoshino", "haruna"
|
|
))
|
|
email += random.choice(("", ".", "_", "-"))
|
|
# random a-z chars
|
|
for i in range(random.randint(3, 9)):
|
|
email += chr(97 + random.randint(0, 24))
|
|
# ~50% chance
|
|
if random.randbytes(1):
|
|
# random digits
|
|
email += compat_str(random.randint(0, 9999))
|
|
return email + "@" + random.choice((
|
|
# only include big corp e-mail domains here, fuck centralization
|
|
"gmail.com",
|
|
"outlook.com",
|
|
"live.com",
|
|
"hotmail.com",
|
|
"hotmail.co.uk",
|
|
"yahoo.com",
|
|
"aol.com",
|
|
"aim.com",
|
|
"yandex.ru",
|
|
"mail.ru",
|
|
))
|
|
|
|
|
|
def regex_search_string(regexes, string, default=None, multiple=False, whole_match=False):
|
|
if not isinstance(regexes, list):
|
|
regexes = [regexes]
|
|
results = []
|
|
for regex in regexes:
|
|
if multiple:
|
|
matches = re.finditer(regex, string)
|
|
for match in matches:
|
|
if not whole_match:
|
|
match = match.group(1)
|
|
results.append(match)
|
|
else:
|
|
match = re.search(regex, string)
|
|
if match:
|
|
if not whole_match:
|
|
match = match.group(1)
|
|
return match
|
|
if multiple:
|
|
return results
|
|
return default
|
|
|
|
|
|
def dump_qs(obj):
|
|
if py_major_ver == 2:
|
|
old_qs = obj.iteritems()
|
|
else:
|
|
old_qs = list(obj.items())
|
|
# sorting by key to unify the result string between python versions
|
|
# https://stackoverflow.com/a/3295662/8222484
|
|
old_qs.sort()
|
|
qs = []
|
|
not_flat = True
|
|
while not_flat:
|
|
not_flat = False
|
|
for old_qs_element in old_qs:
|
|
if isinstance(old_qs_element[1], (compat_str, int, float)):
|
|
qs.append((old_qs_element[0], old_qs_element[1]))
|
|
elif isinstance(old_qs_element[1], (dict)):
|
|
for subkey in old_qs_element[1]:
|
|
if old_qs_element[1][subkey] is not None:
|
|
qs.append(
|
|
(old_qs_element[0] + "[" + subkey + "]", old_qs_element[1][subkey]))
|
|
if isinstance(old_qs_element[1][subkey], (dict, list)):
|
|
not_flat = True
|
|
elif isinstance(old_qs_element[1], (list)):
|
|
for index in range(len(old_qs_element[1])):
|
|
element = old_qs_element[1][index]
|
|
if element is not None:
|
|
qs.append(
|
|
(old_qs_element[0] + "[" + compat_str(index) + "]", element))
|
|
if isinstance(element, (dict, list)):
|
|
not_flat = True
|
|
if not_flat:
|
|
old_qs = qs
|
|
qs = []
|
|
strng = ""
|
|
for el in qs:
|
|
strng += qs_quote(compat_str(el[0]).encode("utf-8")) + "=" + \
|
|
qs_quote(compat_str(el[1]).encode("utf-8")) + "&"
|
|
return strng[:-1]
|
|
|
|
|
|
def absolute_url(new_url, old_url):
|
|
if new_url.startswith("http:") or new_url.startswith("https:"):
|
|
return new_url
|
|
|
|
old = urlparse(old_url)
|
|
scheme = old.scheme if old.scheme is not None else "http"
|
|
|
|
if new_url.startswith("://"):
|
|
return scheme + new_url
|
|
if new_url.startswith("//"):
|
|
return scheme + ":" + new_url
|
|
|
|
hostname = old.netloc
|
|
|
|
if new_url.startswith("/"):
|
|
return scheme + "://" + hostname + new_url
|
|
|
|
# like "hostname/path?query", if other checks fail
|
|
return scheme + "://" + new_url
|