If the content on your page is generated by JavaScript, try Selenium. I think it has all the functionality you need.
Your code will then look like this:
### Let's import Selenium!
from selenium.webdriver import Firefox,FirefoxOptions
### At first, we need to say Selenium it should not show graphical window, so we will use Firefox in headless mode.
### We do so by creating instance of FirefoxOptions and setting its attribute 'headless' to True
opt=FirefoxOptions()
opt.headless=True
### Now, we create the actual Firefox instance and we pass it our FirefoxOptions as keyword argument 'options'
ffx=Firefox(options=opt)
### We visit your website with ffx.get()
ffx.get("https://wuzzuf.net/jobs/p/xGYIYbJlYhsC-Senior-Python-Developer-Cairo- Egypt?o=1&l=sp&t=sj&a=python|search-v3|hpb")
### Let's now search for your spans with ffx.find_elements_by_css_selector()
elems=ffx.find_elements_by_css_selector("div.css-rcl8e5:nth-child(5)>span")
### And print the elements
for elem in elems:
print(elem.get_attribute('outerHTML'))
This (at least at my case) outputs:
<span class="css-wn0avc">Salary<!-- -->:</span>
<span class="css-47jx3m"><span class="css-4xky9y">Confidential</span></span>
To access the second element, use elems[-1]
, and elems[-1].get_attribute('outerHTML')
to get its html source.
But do not forget to install Selenium with
pip install selenium
And you should have Firefox with geckodriver installed.