Python Beautifulsoup cannot get svg tags

Asked By: user15552005

enter image description hereI am trying to get each small circles that shows which result is banker or player. I need to get the result from each 35 tables.

from selenium import webdriver
import time
from bs4 import BeautifulSoup

driver = webdriver.Chrome('C:/chromedriver/chromedriver.exe')
driver.get('http://ggl-maxim.com/')

driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[1]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[2]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/button[1]').click()

time.sleep(2)
driver.get('http://ggl-maxim.com/api/popup/popup_menu.asp?mobile=0&lobby=EVOLUTION')

time.sleep(10)
html = driver.page_source
bs = BeautifulSoup(html, 'html.parser')
targets = bs.find_all('svg')

print(targets)

However, by this code I cannot get the svg tag. How can I?

Else, if anyone knows how to get this casino’s value please tell me.


Solution

Answered By: Anonymous

With Selenium I’d use css selector:

driver.find_elements_by_css_selector(".svg--1nrnH")

Update for Selenium: wait for iframe. This is the reason why element could not be found.

from selenium import webdriver
import time
from bs4 import BeautifulSoup
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


driver = webdriver.Chrome(executable_path='/snap/bin/chromium.chromedriver')
driver.get('http://ggl-maxim.com/')

driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[1]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[2]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/button[1]').click()

time.sleep(2)
driver.get('http://ggl-maxim.com/api/popup/popup_menu.asp?mobile=0&lobby=EVOLUTION')
wait = WebDriverWait(driver, 20)
wait.until(EC.frame_to_be_available_and_switch_to_it("gameIframe"))
wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".svg--1nrnH")))
targets = driver.find_elements_by_css_selector(".svg--1nrnH")
res = []
for el in targets:
    print(len(el.get_attribute("innerHTML")))
    res.append(el.get_attribute('innerHTML'))
print(*res, sep='n')
techinplanet staff

techinplanet staff


Windows 10 Kaufen Windows 10 Pro Office 2019 Kaufen Office 365 Lizenz Windows 10 Home Lizenz Office 2019 Home Business Kaufen windows office 365 satın al follower kaufen instagram follower kaufen porno