Im trying to scrape the title from a website, but it is only returning 1 title. How can I get all the titles?
Below is one of the elements Im trying to fetch using xpath (starts-with):
<div id="post-4550574" class="post-box " data-permalink="https://hypebeast.com/2019/4/undercover-nike-sfb-mountain-sneaker-release-info" data-title="The UNDERCOVER x Nike SFB Mountain Pack Gets a Release Date"><div class="post-box-image-container fixed-ratio-3-2">
This is my current code:
from selenium import webdriver
import requests
from bs4 import BeautifulSoup as bs
driver = webdriver.Chrome('/Users/Documents/python/Selenium/bin/chromedriver')
driver.get('https://hypebeast.com/search?s=nike+undercover')
element = driver.find_element_by_xpath(".//*[starts-with(@id, 'post-')]")
print(element.get_attribute('data-title'))
Output:
The UNDERCOVER x Nike SFB Mountain Pack Gets a Release Date
I was expecting a lot more title but only returning one result.