Dzień dobry wszystkim...Mam takie pytanie próbuję pobrać tekst ze strony i przypisać je do zmiennej:
1 drużyna homeTeam 2 drużyna awayTeam
Przykład:
https://www.flashscore.com/match/n9YYdJ4C/#h2h;overall
<a href="#" class="participant-imglink" onclick="window.open('/team/nice/YagoQJpq'); return false;">Nice</a>
i druga drużyna
<a href="#" class="participant-imglink" onclick="window.open('/team/rennes/d2nnj1IE'); return false;">Rennes</a>
Chcę pobrać tekst sam Nice i przypisać do homeTeam oraz pobrać Rennes i przypisać do awwayTeam
Mój pseudo kod ;):
browser = webdriver.Chrome(
("/usr/bin/chromedriver"),
chrome_options=options)
browser.get("https://www.flashscore.com/football/")
sleep(3)
source = browser.page_source # Get the entire page source from the browser
if browser is not None :browser.close() # No need for the browser so close it
soup = BeautifulSoup(source,'html.parser')
try:
Tags = soup.select("div.leagues--live div[title='Click for match detail!'][id]") # get the elements using css selectors
for tag in Tags: # loop through them
matchId = ((tag['id']).replace('g_1_', ''))
matchLink = ("https://www.flashscore.com/match/" + matchId + "/#h2h;overall")
print(matchLink)
browser1 = webdriver.Chrome(
("/usr/bin/chromedriver"),
chrome_options=options)
browser1.get(matchLink)
sleep(3)
source1 = browser1.page_source # Get the entire page source from the browser
soup1 = BeautifulSoup(source1,'html.parser')
Tags1 = soup1.select("div.flashscore")
for tag1 in Tags1:
name = tag.find('a').find('class').text
print(tag1)
browser1.quit()
except Exception as e:
print(e)
Jeśli mógłbym prosić o pomoc jak to pobrać z góry dziękuje...