Загрузка...

Скрипт Авто + в раздачи Ключи от стим и акки

Тема в разделе Программирование создана пользователем zxcFlezyi 11 май 2025. (поднята 6 июн 2025 в 12:12) 147 просмотров

Загрузка...
  1. zxcFlezyi
    zxcFlezyi Автор темы 11 май 2025 65 26 окт 2024
    так как это моя первая тема с использованием LOLZ я не знал что тут есть API а еще хз как его использовать так что не судите строго.

    В 'name': 'xf_session'
    xf_tfa_trust_8802493

    надо сменить на свои куки

    и изменить свой путь до geckodriver.exe​
    Python
    import concurrent.futures
    import threading

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.common.keys import Keys
    from selenium.webdriver.firefox.service import Service
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    from selenium.common.exceptions import TimeoutException, NoSuchElementException
    from bs4 import BeautifulSoup
    import time
    import random

    geckodriver_path = r"C:\Users\Asus\Desktop\LZT\geckodriver.exe"

    options = webdriver.FirefoxOptions()
    options.add_argument("--headless")

    service = Service(executable_path=geckodriver_path)
    driver = webdriver.Firefox(service=service, options=options)


    def random_delay(min_sec=1, max_sec=3):
    delay = random.uniform(min_sec, max_sec)
    time.sleep(delay)
    return delay

    def post_reply(thread_url):
    try:
    print(f" Заходим на тему: {thread_url}...")
    driver.get(thread_url)

    WebDriverWait(driver, 15).until(
    EC.presence_of_element_located((By.CSS_SELECTOR, '#QuickReply'))
    )

    time.sleep(2)

    success = False

    try:
    editor_area = WebDriverWait(driver, 5).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR,
    '#QuickReply > div.defEditor > div.fr-box.messageText.baseHtml.LolzteamEditorSimple'))
    )
    editor_area.click()
    time.sleep(1)

    editor = WebDriverWait(driver, 5).until(
    EC.presence_of_element_located((By.CSS_SELECTOR,
    '[contenteditable="true"]'))
    )
    editor.clear()
    editor.click()
    editor.send_keys("+")
    print(" Метод 1: Плюсик вставлен, все чики-пуки!")
    success = True
    except Exception as e:
    print(f" Метод 1 не прокатил: {e}")

    if not success:
    try:
    frames = driver.find_elements(By.CSS_SELECTOR, 'iframe')
    for frame in frames:
    try:
    driver.switch_to.frame(frame)
    body = driver.find_element(By.TAG_NAME, 'body')
    body.clear()
    body.send_keys("+")
    driver.switch_to.default_content()
    print(" Метод 2: Плюсик вставлен через iframe, все окей!")
    success = True
    break
    except:
    driver.switch_to.default_content()
    continue
    except Exception as e:
    print(f" Метод 2 не зашел: {e}")
    driver.switch_to.default_content()

    if not success:
    try:
    js_script = """
    document.querySelector('[contenteditable="true"]').innerHTML = '+';
    """
    driver.execute_script(js_script)
    print(" Метод 3: JS сделал свое дело, плюсик на месте!")
    success = True
    except Exception as e:
    print(f" Метод 3 не сработал: {e}")

    if not success:
    try:
    possible_selectors = [
    '.fr-element',
    '.fr-view',
    'textarea[name="message"]',
    '[contenteditable="true"]',
    '.messageText',
    '.richEditor'
    ]

    for selector in possible_selectors:
    try:
    element = WebDriverWait(driver, 2).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, selector))
    )
    element.click()
    element.clear()
    element.send_keys("+")
    print(f" Метод 4: Плюсик вставлен через селектор {selector}, все гуд!")
    success = True
    break
    except:
    continue
    except Exception as e:
    print(f" Метод 4 не прокатил: {e}")

    if not success:
    print(" Не удалось вставить плюсик, возможно, что-то пошло не так...")
    return False

    try:
    driver.save_screenshot(f"before_submit_{int(time.time())}.png")
    except:
    pass

    try:
    submit_selectors = [
    'input[type="submit"]',
    'button[type="submit"]',
    '.button--primary',
    '.formSubmitRow-controls button',
    '#QuickReply input[type="submit"]',
    'button.button--icon--reply'
    ]

    for selector in submit_selectors:
    try:
    submit_button = WebDriverWait(driver, 3).until(
    EC.element_to_be_clickable((By.CSS_SELECTOR, selector))
    )
    submit_button.click()
    print(f" Кнопка отправки через селектор {selector} нажата, все ок!")

    time.sleep(3)
    print(f" Плюсик успешно отправлен в теме: {thread_url}")
    return True
    except:
    continue

    active_element = driver.switch_to.active_element
    active_element.send_keys(Keys.RETURN)
    print(" Отправили форму через Enter, все четко!")

    time.sleep(3)
    print(f" Плюсик успешно отправлен в теме через Enter: {thread_url}")
    return True

    except Exception as e:
    print(f" Не удалось отправить форму: {e}")

    try:
    driver.save_screenshot(f"error_submit_{int(time.time())}.png")
    except:
    pass

    return False

    except Exception as e:
    print(f" Ошибка при отправке плюсика в теме {thread_url}: {e}")
    return False

    def parse_page(page_url):
    try:
    driver.get(page_url)

    WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.CSS_SELECTOR, 'div.listBlock.lastPost'))
    )

    last_height = driver.execute_script("return document.body.scrollHeight")

    for _ in range(5):
    driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")

    time.sleep(2)

    new_height = driver.execute_script("return document.body.scrollHeight")

    if new_height == last_height:
    break

    last_height = new_height

    page_source = driver.page_source

    soup = BeautifulSoup(page_source, 'html.parser')

    discussion_items = soup.select('div.discussionListItem')

    last_post_blocks = soup.select('div.discussionListItem div.listBlock.lastPost')

    results = []
    for block in last_post_blocks:
    author = block.select_one('a.username').text.strip() if block.select_one('a.username') else "Неизвестный автор"

    post_time_span = block.select_one('span.startDate')
    if post_time_span:
    post_time = post_time_span.text.strip()
    else:

    post_time = block.select_one('time').text.strip() if block.select_one('time') else "Неизвестное время"

    thread_main_block = block.find_parent('div', class_='discussionListItem--Wrapper').select_one('a.listBlock.main')
    if thread_main_block and 'href' in thread_main_block.attrs:
    post_link_url = thread_main_block['href']
    if post_link_url.startswith('/threads/'):
    post_link_url = 'https://lolz.live' + post_link_url
    else:
    thread_link = block.find_parent('div', class_='discussionListItem').select_one('a[href*="/threads/"]')
    if thread_link and 'href' in thread_link.attrs:
    post_link_url = thread_link['href']
    if not post_link_url.startswith('http'):
    post_link_url = 'https://lolz.live' + post_link_url
    else:
    post_link_url = "Нет ссылки"

    if post_link_url != "Нет ссылки":
    if post_link_url.startswith("https://lolz.live/threads/"):
    post_link_url = post_link_url.replace("https://", "")
    elif post_link_url.startswith("/threads/"):
    post_link_url = "lolz.live" + post_link_url
    elif post_link_url.startswith("threads/"):
    post_link_url = "lolz.live/" + post_link_url
    elif "/threads/" in post_link_url:
    thread_id = post_link_url.split("/threads/")[1].split("/")[0]
    post_link_url = f"lolz.live/threads/{thread_id}/"

    results.append({
    'author': author,
    'time': post_time,
    'link': post_link_url
    })

    next_page = soup.select_one('div.PageNav a.text[data-nav="next"]')
    next_page_url = None
    if next_page and 'href' in next_page.attrs:
    next_page_url = next_page['href']
    if not next_page_url.startswith('http'):
    next_page_url = 'https://lolz.live' + next_page_url

    return results, next_page_url

    except Exception as e:
    print(f" Ошибка при парсинге страницы {page_url}: {e}")
    return [], None

    def process_thread(thread_url, file, file_lock):
    reply_status = post_reply(thread_url)
    with file_lock:
    file.write(f"Ответ отправлен: {'Успешно' if reply_status else 'Ошибка'}\n")
    file.write("-" * 50 + "\n")
    file.flush()


    file_lock = threading.Lock()
    try:
    driver.get("https://lolz.live/")
    driver.add_cookie({
    'name': 'xf_session',
    'value': 'ТУТ КУКИ',
    'domain': 'lolz.live'
    })
    driver.add_cookie({
    'name': 'xf_tfa_trust_8802493',
    'value': 'ТУТ КУКИ',
    'domain': 'lolz.live'
    })

    pages_to_parse = [
    "https://lolz.live/forums/21/?last_post_user_id=0",
    "https://lolz.live/forums/21/page-2?last_post_user_id=0",
    "https://lolz.live/forums/21/page-3?last_post_user_id=0",
    "https://lolz.live/forums/21/page-4?last_post_user_id=0",
    "https://lolz.live/forums/21/page-5?last_post_user_id=0",
    "https://lolz.live/forums/21/page-6?last_post_user_id=0"
    ]

    all_results = []

    print(f" Начинаем парсинг указанных страниц...")

    with open('last_posts.txt', 'w', encoding='utf-8') as file:
    for page_count, current_url in enumerate(pages_to_parse, 1):
    print(f" Парсим страницу #{page_count}: {current_url}...")

    results, _ = parse_page(current_url)

    for result in results:
    with file_lock:
    file.write(f"Автор: {result['author']}\n")
    file.write(f"Время: {result['time']}\n")
    file.write(f"Ссылка: {result['link']}\n")
    file.flush()

    valid_thread_urls = []
    for result in results:
    if result['link'] != "Нет ссылки":
    thread_url = result['link']
    if not thread_url.startswith("http"):
    thread_url = "https://" + thread_url
    valid_thread_urls.append(thread_url)

    with concurrent.futures.ThreadPoolExecutor(max_workers=60) as executor:
    futures = [executor.submit(process_thread, url, file, file_lock) for url in valid_thread_urls]

    for future in concurrent.futures.as_completed(futures):
    try:
    future.result()
    except Exception as e:
    print(f" Ошибка в потоке: {e}")

    all_results.extend(results)

    time.sleep(random.uniform(3, 5))

    current_url = "https://lolz.live/forums/21/"
    page_count = 1

    while True:
    print(f" Бесконечный парсинг продолжается. Страница #{page_count}: {current_url}...")

    results, next_page_url = parse_page(current_url)

    for result in results:
    with file_lock:
    file.write(f"Автор: {result['author']}\n")
    file.write(f"Время: {result['time']}\n")
    file.write(f"Ссылка: {result['link']}\n")
    file.flush()

    valid_thread_urls = []
    for result in results:
    if result['link'] != "Нет ссылки":
    thread_url = result['link']
    if not thread_url.startswith("http"):
    thread_url = "https://" + thread_url
    valid_thread_urls.append(thread_url)

    with concurrent.futures.ThreadPoolExecutor(max_workers=60) as executor:
    futures = [executor.submit(process_thread, url, file, file_lock) for url in valid_thread_urls]

    for future in concurrent.futures.as_completed(futures):
    try:
    future.result()
    except Exception as e:
    print(f" Ошибка в потоке: {e}")

    all_results.extend(results)

    if next_page_url:
    current_url = next_page_url
    page_count += 1
    time.sleep(2)
    else:
    print(" Дошли до последней страницы! Начинаем парсинг сначала...")
    current_url = "https://lolz.live/forums/21/"
    page_count = 1
    time.sleep(5)

    except KeyboardInterrupt:
    print("\n Парсинг был остановлен пользователем.")

    except Exception as e:
    print(f" Произошла ошибка: {e}")

    finally:
    driver.quit()
    print(f" Всего было найдено {len(all_results)} постов.")
    print(" Результаты сохранены в файл last_posts.txt")
     
    1. Посмотреть предыдущие комментарии (7)
    2. zxcFlezyi Автор темы
      Нинтендо, скинь мб если похуй не будет реворкну
    3. Нинтендо
      zxcFlezyi, поищи на форуме, у меня ссылки нет
Top