Answer the question
In order to leave comments, you need to log in
How to click a button on a site, parsing?
I have a parser (don't scold me for it), it does the job fine, but there was a problem that could not be solved. I can't click on the site button. I'm using selenium to click on a button, but it's not convenient for my task. Advise how else you can click the buttons of sites and it is desirable that the browser does not open. Or help with the error, it will be below the code.
import requests
from bs4 import BeautifulSoup as BS
import re
import webbrowser
from selenium import webdriver
def BUY_SK(url):
r = requests.get(url)
html = BS(r.content, 'html.parser')
#hidden_tags = str(html.find("input", {"type": "hidden"}))[50:][:-3]
#webbrowser.open(url, new=2)
driver = webdriver.Firefox()
driver.get(url)
element = driver.find_element_by_css_selector('.snap._color.buy-user-good')
element.click() # Ошибка из-за этого элемента
def SKINKEEN():
regular = re.compile(r'<a\s+(?:[^>]*?\s+)?href=([""])(.*?)\1')
r = requests.get('https://skinkeen.ru/')
html = BS(r.content, 'html.parser')
for el in html.select('.item_view'):
title = el.select('.item_view__info > span')
title = title[0].text[8:][:-4]
if int(title) >= 45:
gun__ = all_links = el.find_all('a', href=True)
gun = regular.split(str(gun__[0]))
gun__info_ = html.select('.item_view > a')
print('\n[INFO] Найдено подходящие оружие! Скидка', str(title) + '%\n', gun__info_[0].text)
print('https://skinkeen.ru/' + str(gun[2]), '\n')
BUY_SK('https://skinkeen.ru/' + str(gun[2]))
else:
print('[INFO] Оружие не подходит: Скидка', str(title) + '%')
SKINKEEN()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question