from cmath import sin
from email import header
from webbrowser import get
from wsgiref.headers import Headers
from bs4 import BeautifulSoup
import requests
import urllib3
import urllib
import pandas as pd
import os
import re
import time
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
from selenium.webdriver.chrome.options import Options
from zipfile import *
import zipfile
from os.path import basename
import gspread
from selenium.common.exceptions import TimeoutException
headers = {
'Accept-Encoding': 'gzip, deflate, sdch',
'Accept-Language': 'en-US,en;q=0.8',
'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Cache-Control': 'max-age=0',
'Connection': 'keep-alive',
}
sa = gspread.service_account(filename="C:/Users/user/Documents/sheetsapi.json")
sh = sa.open("only74kotc")
sheet = sh.worksheet("dll")
http = urllib3.PoolManager()
options = webdriver.ChromeOptions()
options.add_argument("--log-level=3")
options.add_argument("user-data-dir=C:\\Users\\user\\AppData\\Local\\Google\\Chrome Beta\\User Data\\")
options.binary_location = "C:\\Program Files\\Google\\Chrome Beta\\Application\\chrome.exe"
options.add_experimental_option("prefs", {
"download.default_directory": "C:\\Users\\user\\Downloads",
"download.prompt_for_download": False,
"download.directory_upgrade": True,
"safebrowsing.enabled": True
})
# start = sheet.find(None, in_column=2)
start_row = 966
end_row = start_row + 100
for i in range(start_row, end_row + 1):
url = sheet.cell(i, 1).value
try:
source = requests.get (url, headers=headers, timeout=10, allow_redirects=False,)
except:
time.sleep(20)
source = requests.get (url, headers=headers, timeout=10, allow_redirects=False,)
soup = BeautifulSoup(source.text,'html.parser')
cont = soup.find('div', id="grid-container")
mainlist = cont.find('section', class_="file-info-grid")
version = mainlist.find('div', class_="right-pane").find_all('p')[0].text
bit = mainlist.find('div', class_="right-pane").find_all('p')[1].text
size = mainlist.find('div', class_="right-pane").find_all('p')[2].text
lang = mainlist.find('div', class_="right-pane").find_all('p')[3].text
company = mainlist.find('div', class_="right-pane").find_all('p')[4].text
description = mainlist.find('div', class_="right-pane").find_all('p')[5].text
dlink = mainlist.find('div', class_="download-link").a["href"]
sheet.update_cell(i, 3, version)
bot = webdriver.Chrome(executable_path="chromedriver.exe", chrome_options=options)
wait = WebDriverWait(bot, 10)
sheet.update_cell(i, 2, "trying")
bot.get("https://www.dll-files.com"+dlink+"")
bot.implicitly_wait(10)
WebDriverWait(bot, 30).until(EC.text_to_be_present_in_element((By.XPATH, '/html/body/section[2]/div/article/div[3]/p[2]'), "automatically"))
filename = bot.find_element(By.XPATH, '/html/body/section[2]/div/article/div[3]/p[2]/a').text.replace("download ", "").replace(".dll here", "")
file_path = "C:/Users/user/Downloads/"+filename+".zip"
wait = WebDriverWait(bot, 120) # Wait up to 2 minutes for the file to download
wait.until(lambda x: os.path.isfile(file_path))
print("zip 1 download sucessful")
with ZipFile('C:/Users/user/Downloads/'+filename+'.zip', 'r') as zipObj:
listOfFileNames = zipObj.namelist()
for zipname in listOfFileNames:
if zipname.lower().endswith('.dll'):
zipObj.extract(zipname, 'C:/Users/user/Downloads/dll')
print("zip 1 uncompress finished")
wait.until(lambda x: os.path.isfile('C:/Users/user/Downloads/dll/'+filename+'.dll'))
zip = zipfile.ZipFile('C:/Users/user/Downloads/dll/'+filename+' '+bit+'.zip', 'w')
zip.write('C:/Users/user/Downloads/dll/'+filename+'.dll', basename('C:/Users/user/Downloads/dll/'+filename+'.dll'))
zip.close()
print("zip 1 repack finished")
os.remove('C:/Users/user/Downloads/dll/'+filename+'.dll')
os.remove('C:/Users/user/Downloads/'+filename+'.zip')
try:
mainlist2 = cont.find_all('section', class_="file-info-grid")[1]
try:
bit2 = mainlist2.find('div', class_="right-pane").find_all('p')[1].text
if bit==bit2:
print("same bit found")
else:
dlink2 = mainlist2.find('div', class_="download-link").a["href"]
bot.get("https://www.dll-files.com"+dlink2+"")
bot.implicitly_wait(10)
WebDriverWait(bot, 30).until(EC.text_to_be_present_in_element((By.XPATH, '/html/body/section[2]/div/article/div[3]/p[2]'), "automatically"))
filename = bot.find_element(By.XPATH, '/html/body/section[2]/div/article/div[3]/p[2]/a').text.replace("download ", "").replace(".dll here", "")
file_path = "C:/Users/user/Downloads/"+filename+".zip"
wait = WebDriverWait(bot, 120) # Wait up to 2 minutes for the file to download
wait.until(lambda x: os.path.isfile(file_path))
with ZipFile('C:/Users/user/Downloads/'+filename+'.zip', 'r') as zipObj:
listOfFileNames = zipObj.namelist()
for zipname in listOfFileNames:
if zipname.lower().endswith('.dll'):
zipObj.extract(zipname, 'C:/Users/user/Downloads/dll')
print("zip 2 uncompress finished")
wait.until(lambda x: os.path.isfile('C:/Users/user/Downloads/dll/'+filename+'.dll'))
zip = zipfile.ZipFile('C:/Users/user/Downloads/dll/'+filename+' '+bit2+'.zip', 'w')
zip.write('C:/Users/user/Downloads/dll/'+filename+'.dll', basename('C:/Users/user/Downloads/dll/'+filename+'.dll'))
zip.close()
print("zip 2 repack finished")
os.remove('C:/Users/user/Downloads/dll/'+filename+'.dll')
os.remove('C:/Users/user/Downloads/'+filename+'.zip')
except:
print("bit not available bit found")
except:
print("No second file")
myvalue = i
###---------------------Now uploading files to site------------------------------###
bot.get("https://onlyhax.com/dashboard/Upload/create")
bot.implicitly_wait(10)
try:
WebDriverWait(bot, 10).until(EC.text_to_be_present_in_element((By.XPATH, '/html/body/main/div/div/div/div/div/div[1]'), "Login"))
time.sleep(3)
login_button = bot.find_element(By.XPATH, '/html/body/main/div/div/div/div/div/div[2]/form/div[4]/div/button')
for i in range(1):
login_button.click()#login button
time.sleep(10)
except:
print("Login Bypassed")
print("wait for Upload File")
WebDriverWait(bot, 10).until(EC.text_to_be_present_in_element((By.XPATH, '/html/body/main/div/div/main/div[2]/h1'), "Upload File"))
print("trying Upload File 32")
try:
simp_path = 'C:/Users/user/Downloads/dll/'+filename+' 32.zip'
print(simp_path)
file_input = bot.find_element(By.XPATH, '//*[@id="file32"]')
abs_path = os.path.abspath(simp_path)
file_input.send_keys(abs_path)
time.sleep(3)
except:
print("32 bit not found")
print("trying Upload File 64")
try:
simp_path = 'C:/Users/user/Downloads/dll/'+filename+' 64.zip'
print(simp_path)
file_input = bot.find_element(By.XPATH, '//*[@id="file64"]')
abs_path = os.path.abspath(simp_path)
file_input.send_keys(abs_path)
time.sleep(3)
except:
print("64 bit not found")
num_chars = len(filename)
if num_chars < 18:
thumbfont = 80
elif num_chars >= 18 and num_chars <= 28:
thumbfont = 60
else:
thumbfont = 40
os.system("ffmpeg -i C:/Users/user/Documents/dll.jpg -vf drawtext=\"fontfile=/Users/user/AppData/Local/Microsoft/Windows/Fonts/LATO-BLACK.TTF: text="+str(filename)+".dll: fontcolor=black: fontsize="+str(thumbfont)+": shadowcolor=white: shadowx=0: shadowy=0: box=1: boxcolor=white: boxborderw=20: x=250:y=280\" \"G:/"+filename+".jpg\"")
simp_path = 'G:/'+filename+'.jpg'
print(simp_path)
file_input = bot.find_element(By.XPATH, '//*[@id="image_file"]')
abs_path = os.path.abspath(simp_path)
file_input.send_keys(abs_path)
print("thumbnail upload done")
time.sleep(3)
bot.find_element(By.XPATH, '//*[@id="Uploadname"]').send_keys(""+filename+".dll")
cat = bot.find_element(By.XPATH, '/html/body/main/div/div/main/form/li[10]/select')
for i in range(1):
cat.click()#category
time.sleep(1)
cat.send_keys(filename[0])
bot.find_element(By.XPATH, '//*[@id="Uploadnamec"]').send_keys(company)
bot.find_element(By.XPATH, '//*[@id="lovedesc"]').send_keys(description)
finalbutton = bot.find_element(By.XPATH, '/html/body/main/div/div/main/form/button')
for i in range(1):
finalbutton.click()#finalbutton
#Wait for file upload
try:
WebDriverWait(bot, 300).until(EC.text_to_be_present_in_element((By.XPATH, '/html/body/main/div/div/main/div[2]/span'), "Upload Created Successfully"))
sheet.update_cell(myvalue, 2, "done")
except TimeoutException:
bot.refresh()
try:
WebDriverWait(bot, 10).until(EC.text_to_be_present_in_element((By.XPATH, '/html/body/main/div/div/main/div[2]/span'), "Upload Created Successfully"))
sheet.update_cell(myvalue, 2, "done")
except TimeoutException:
sheet.update_cell(myvalue, 2, "maybe 505")
print("done")
time.sleep(1)
bot.quit()
0 comments:
Post a Comment