2016-08-06 13:03:39 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2016-08-06 23:46:20 +00:00
|
|
|
from bs4 import BeautifulSoup
|
2016-08-06 13:03:39 +00:00
|
|
|
from selenium import webdriver
|
|
|
|
from selenium.webdriver.common.keys import Keys
|
|
|
|
from selenium.common.exceptions import NoSuchElementException
|
2017-09-09 12:40:28 +00:00
|
|
|
import glob, multiprocessing, re, requests, urllib.request, urllib.error, urllib.parse, time, os
|
|
|
|
import setuptools
|
2016-08-06 23:46:20 +00:00
|
|
|
|
2017-09-10 18:26:36 +00:00
|
|
|
useragent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0"
|
2017-09-12 18:47:02 +00:00
|
|
|
session = None
|
2017-09-14 14:23:15 +00:00
|
|
|
driver = None
|
|
|
|
|
|
|
|
def status():
|
|
|
|
global driver
|
2017-09-10 18:26:36 +00:00
|
|
|
|
2017-09-09 12:40:28 +00:00
|
|
|
if "Benutzername oder E-Mail-Adresse:" not in driver.page_source and 'href="login/"' not in driver.page_source:
|
2016-08-06 13:03:39 +00:00
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
def loadPage(url, period=5, init = False):
|
|
|
|
global driver
|
|
|
|
|
|
|
|
if not (init or status()):
|
|
|
|
login()
|
2016-08-06 13:03:39 +00:00
|
|
|
driver.get(url)
|
|
|
|
time.sleep(period)
|
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
def loginHandler(user = setuptools.user(), password = setuptools.password()):
|
|
|
|
loadPage("https://scriptzbase.org/login/", 3, True)
|
2016-08-06 13:03:39 +00:00
|
|
|
|
2017-09-09 12:40:28 +00:00
|
|
|
curfield = driver.find_element_by_name("login")
|
2016-08-06 13:03:39 +00:00
|
|
|
curfield.send_keys(user)
|
|
|
|
|
2017-09-09 12:40:28 +00:00
|
|
|
curfield = driver.find_element_by_name("password")
|
2016-08-06 13:03:39 +00:00
|
|
|
curfield.send_keys(password)
|
|
|
|
|
|
|
|
curfield.send_keys(Keys.RETURN)
|
2016-08-06 23:46:20 +00:00
|
|
|
time.sleep(3)
|
2016-08-06 13:03:39 +00:00
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
return status()
|
2016-08-06 13:03:39 +00:00
|
|
|
|
|
|
|
class LoginError(Exception):
|
|
|
|
pass
|
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
def login():
|
|
|
|
global driver, session
|
2017-09-12 18:47:02 +00:00
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
if not (status() or loginHandler()):
|
2016-08-06 13:03:39 +00:00
|
|
|
raise LoginError("Login failed.")
|
2017-01-30 23:52:56 +00:00
|
|
|
|
2017-09-09 12:40:28 +00:00
|
|
|
session = requests.Session()
|
|
|
|
kekse = driver.get_cookies()
|
2016-08-06 13:03:39 +00:00
|
|
|
|
2017-09-09 12:40:28 +00:00
|
|
|
for keks in kekse:
|
2017-09-10 07:48:49 +00:00
|
|
|
session.cookies.set(keks["name"], keks["value"])
|
2016-08-06 13:03:39 +00:00
|
|
|
|
2017-09-12 18:47:02 +00:00
|
|
|
session.headers.update({"User-Agent": useragent})
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
def fileHandler(url, retry = False):
|
|
|
|
global session
|
|
|
|
|
|
|
|
try:
|
|
|
|
fid = url.split("=")[1]
|
2017-09-14 14:10:08 +00:00
|
|
|
if not glob.glob("files/sbd%s_*" % fid):
|
2017-09-12 18:47:02 +00:00
|
|
|
res = session.get("https://scriptzbase.org/%s" % url)
|
|
|
|
fname = re.findall("filename=(.+)", res.headers["content-disposition"])[0].split(";")[0].strip('"')
|
|
|
|
|
|
|
|
with open("files/sbd%s_%s" % (fid, fname), "wb") as out:
|
|
|
|
out.write(res.content)
|
|
|
|
|
2017-09-13 16:15:53 +00:00
|
|
|
except (requests.exceptions.ConnectionError, requests.exceptions.ChunkedEncodingError):
|
2017-09-12 18:47:02 +00:00
|
|
|
if not retry:
|
|
|
|
time.sleep(10)
|
|
|
|
fileHandler(url, True)
|
|
|
|
else:
|
|
|
|
raise
|
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
def pageHandler():
|
|
|
|
global driver
|
|
|
|
|
2017-09-12 18:47:02 +00:00
|
|
|
juha = BeautifulSoup(driver.page_source, "html5lib")
|
|
|
|
|
2017-09-09 12:40:28 +00:00
|
|
|
for a in juha.findAll("a"):
|
2017-09-10 08:32:25 +00:00
|
|
|
try:
|
|
|
|
if "/download?version=" in a["href"]:
|
2017-09-12 18:47:02 +00:00
|
|
|
fileHandler(a["href"])
|
2017-09-10 08:32:25 +00:00
|
|
|
except KeyError:
|
|
|
|
pass
|
2017-09-09 12:40:28 +00:00
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
def siteHandler(p):
|
|
|
|
global driver
|
|
|
|
|
|
|
|
loadPage("https://scriptzbase.org/nulled_scripts/?page=" + str(p))
|
2016-08-06 13:03:39 +00:00
|
|
|
|
2017-09-09 12:40:28 +00:00
|
|
|
if driver.current_url[-len(str(p)):] == str(p):
|
2017-09-14 14:23:15 +00:00
|
|
|
pageHandler()
|
|
|
|
return True
|
2017-01-30 23:52:56 +00:00
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
def mainHandler():
|
2017-09-10 08:32:25 +00:00
|
|
|
os.makedirs("files", exist_ok=True)
|
2017-09-14 14:23:15 +00:00
|
|
|
p = 1
|
2016-08-07 19:59:23 +00:00
|
|
|
|
2017-09-14 14:23:15 +00:00
|
|
|
while True:
|
|
|
|
if not siteHandler(p):
|
|
|
|
break
|
|
|
|
p += 1
|
|
|
|
|
|
|
|
def makeDriver():
|
2017-07-19 14:11:13 +00:00
|
|
|
caps = webdriver.DesiredCapabilities().PHANTOMJS.copy()
|
2017-09-10 18:26:36 +00:00
|
|
|
caps["phantoms.page.settings.userAgent"] = useragent
|
2017-09-14 14:23:15 +00:00
|
|
|
return webdriver.PhantomJS(desired_capabilities=caps)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
driver = makeDriver()
|
|
|
|
mainHandler()
|
2017-07-19 14:11:13 +00:00
|
|
|
driver.close()
|