Skip to content

Commit

Permalink
primera version sin steamdb
Browse files Browse the repository at this point in the history
  • Loading branch information
kvvvotheOnnen committed Oct 25, 2024
0 parents commit 9844dab
Show file tree
Hide file tree
Showing 6,587 changed files with 962,507 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
Binary file added __pycache__/cleanName.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/fechaYhora.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/getId.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/headerGen.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/hrefNameProcessor.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/main.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/priceProcess.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/proxyListGen.cpython-311.pyc
Binary file not shown.
Binary file added __pycache__/urlTransformer.cpython-311.pyc
Binary file not shown.
8 changes: 8 additions & 0 deletions cleanName.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import re
def cleanName(texto_fila):
sin_numeros = re.sub(r'\d+', '', texto_fila)
return sin_numeros

def claneNameTrim(texto):
t = texto.split('\n', 1)[0]
return t
Empty file.
Empty file added downloaded_files/pyautogui.lock
Empty file.
10 changes: 10 additions & 0 deletions fechaYhora.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import datetime
import pytz

def fechaYhora():
mi_zona_horaria = pytz.timezone('America/Santiago')
now = datetime.datetime.now(mi_zona_horaria)
hora_actual = now.strftime("%H:%M:%S")
fecha_actual = now.strftime("%Y-%m-%d")
fecha = f"{fecha_actual} {hora_actual}"
return fecha
4 changes: 4 additions & 0 deletions getId.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import re
def getId(txt):
id_juego = re.findall(r'\d+', txt)[0]
return id_juego
42 changes: 42 additions & 0 deletions headerGen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import requests
from proxyListGen import proxyListCheck
def buscarEn(url):
try:
triesList = []
prox = proxyListCheck()
proxy = f"{prox[0]}:{prox[1]}"
session = requests.Session()
while True:
try:
r = session.get(url, proxies={'http':proxy, 'https':proxy}, timeout=7)
break
except requests.exceptions.RequestException as err:
triesList.append(proxy)
prox = proxyListCheck()
proxy = f"{prox[0]}:{prox[1]}"
if proxy in triesList:
while proxy not in triesList:
prox = proxyListCheck()
proxy = f"{prox[0]}:{prox[1]}"
session = requests.Session()
if r.status_code == 200:
return proxy
else:
while True:
try:
r = session.get(url, proxies={'http':proxy, 'https':proxy}, timeout=3)
break
except requests.exceptions.RequestException as err:
triesList.append(proxy)
prox = proxyListCheck()
proxy = f"{prox[0]}:{prox[1]}"
if proxy in triesList:
while proxy not in triesList:
prox = proxyListCheck()
proxy = f"{prox[0]}:{prox[1]}"
session = requests.Session()
return proxy
except requests.exceptions.RequestException as err:
print(err, 'HeaderGen')


12 changes: 12 additions & 0 deletions hrefNameProcessor.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

def hrefNameProcessor(href):
# Extraer la parte después de 'steam-'
contenido = href.split('steam-')[1]

# Si hay un segundo 'steam-' o final del segmento de la URL, cortar allí
if '-steam' in contenido:
contenido = contenido.split('-steam')[0]

# Reemplazar guiones por espacios para un nombre más legible
contenido_limpio = contenido.replace('-', ' ')
return contenido_limpio
4 changes: 4 additions & 0 deletions integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from main import scrap

juego = scrap('dark souls')
print(juego)
47 changes: 47 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
from seleniumbase import SB
import re
from urlTransformer import juegoURL
from cleanName import cleanName, claneNameTrim
from priceProcess import priceProcess
from hrefNameProcessor import hrefNameProcessor
from getId import getId
from fechaYhora import fechaYhora

def scrap(juego):
with SB(uc=True, headless=True) as sb:
try:
nombreJuego = juegoURL(juego)
url = f"https://www.eneba.com/latam/store/all?text={nombreJuego}&enb_campaign=Main%20Search&enb_content=search%20dropdown%20-%20input&enb_medium=input&enb_source=https%3A%2F%2Fwww.eneba.com%2F&enb_term=Submit"
sb.get(url)
cards = sb.find_elements('.oSVLlh')
price = sb.find_elements('css selector', '.L5ErLT')
names = []
prices = []
plataforma = []
fecha = []
games = []
for i in cards:
name = i.get_attribute('href')
if name and 'steam' in name:
hrefLimpio = hrefNameProcessor(name)
names.append(hrefLimpio)
plataforma.append('steamDB')
date = fechaYhora()
fecha.append(date)
for i in price:
prices.append(i.text)
for n, pr, pl, fe in zip(names, prices, plataforma, fecha):
obj = {
"juego": n,
"precio": pr,
"plataforma": pl,
"fecha": fe
}
games.append(obj)
return games
except ValueError as err:
print(err)
scrap('dark souls')



17 changes: 17 additions & 0 deletions priceProcess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from bs4 import BeautifulSoup

def priceProcess():

with open('pagina_steamdb.txt', 'r', encoding='utf-8') as file:
html_content = file.read()
soup = BeautifulSoup(html_content, 'html.parser')
price_div = soup.find('div', class_='single-price-line')
if price_div:
price_span = price_div.find('span')
if price_span:
precio_juego = price_span.text
return precio_juego
else:
print('No se encontró el <span> con el precio.')
else:
print('No se encontró el div con la clase "single-price-line".')
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
seleniumbase==4.31.6
3 changes: 3 additions & 0 deletions urlTransformer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
def juegoURL(juego):
x = juego.replace(' ', '%20')
return x
1 change: 1 addition & 0 deletions venv/Lib/site-packages/PySocks-1.7.1.dist-info/INSTALLER
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pip
22 changes: 22 additions & 0 deletions venv/Lib/site-packages/PySocks-1.7.1.dist-info/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright 2006 Dan-Haim. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of Dan Haim nor the names of his contributors may be used
to endorse or promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY DAN HAIM "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL DAN HAIM OR HIS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMANGE.
Loading

0 comments on commit 9844dab

Please sign in to comment.