-1
I need to click the 'LIVE NOW' button on the 'https://www.academiadasapostasbrasil.com/' page. I made the following script, but it is giving an error, could not be scrolled into view. Below is the code.
import requests
from bs4 import BeautifulSoup
from selenium import webdriver
url = 'https://www.academiadasapostasbrasil.com/'
web_r = requests.get(url)
web_soup = BeautifulSoup(web_r.text, 'html.parser')
driver = webdriver.Firefox()
driver.get(url)
elemento = driver.find_element_by_xpath('//div[@id="fh_live_tab"]').click()
Thank you very much, Juan Caio. It worked, but now I have another problem. I wanted the HTML code after the click of the button to be sent to me. However, when I return the HTML, I just return the old HTML, without clicking the button. Can you tell me any alternative to get the HTML that is after clicking on the button 'LIVE NOW'? Thank you.
– Héuller Soares
To help you better, as you are returning this html?
– Juan Caio
I am using the following command to return html. html = driver.execute_script("Return Document.documentElement.outerHTML") sel_soup = Beautifulsoup(html, 'html.parser')
– Héuller Soares
You can do the following:
content = driver.page_source
soup = BeautifulSoup(content,'lxml')
Ai vc can get the correct div:dados = soup.find("div", attrs={"id":"fh_live_tab"})
E then you can take the table: ;tabela = dados.find('table', attrs={"class":"competition-today dskt"})
– Juan Caio
Juan, the data variable is coming without the content inside. Thus, the table returns None. [<div class="Boxed tabcontent games_wrapper" id="fh_live_tab" style="opacity: 0.911494; display: block;"><div id="Loader-wrapper" style="height: 80px; width: 642px;"><div class="load-overlay" style="width: 642px; height: 80px;"><div class="ajax-loading big"></div></div></div></div></div>>]
– Héuller Soares
Heuller look at this code here that I performed as a test and compare with your code.
– Juan Caio
Juan, I don’t know why, but is returning me None to the table. I can contact you via some social network?
– Héuller Soares
You can talk to me on Linkedin.
– Juan Caio