I try scraping site in ajax page. I'm just learning python. Sorry if that is an easy question.
Using selenium to load a page and download a piece of code in html. They work perfectly as I want. But I have a problem how to parse these data.
I would like the data to look like this (It may be writing this data to a variable because then I want to transfer it to the mysql database.):
Custom ID:
Name:
Ticket NO:
Rate:
Win:
Data location in html code::
<li class="message">
<div customid="CUSTOM ID">
<span class="name nc-mark-user">NAME</span>
<p>
<span><img src="https://cht.sts.pl/assets/img/accepted.svg" width="15" height="15"> <span class="nc-ticket" onclick="serchTicketHandler('TICKET NO')">RATE / WIN zł</span></span>
</p>
</div>
</li>
My code in python:
import time
from selenium import webdriver
from bs4 import BeautifulSoup
from xml.dom import minidom
options = webdriver.ChromeOptions()
options.add_argument('headless')
browser = webdriver.Chrome(
("C:/Users/backu/Downloads/chromedriver_win32/chromedriver.exe"),
chrome_options=options)
browser.get("https://www.sts.pl/pl/oferta/zaklady-live/")
time.sleep(1)
element = browser.find_element_by_class_name("nc-message-holder")
source = element.get_attribute('innerHTML')
print(source)
browser.close()
I don't know how to read this code now to extract the data I want.
Thank you so much for all the answers.