from bs4 import BeautifulSoup import requests url="URL_HERE" response=requests.get(url) soup=BeautifulSoup(response.content) spans=soup.find_all('span',"_class_here") for span in spans: print(span.text)
Here is what the above code is Doing:
1. We are importing the BeautifulSoup and requests libraries.
2. We are creating a variable called url and assigning it the URL of the page we want to scrape.
3. We are creating a variable called response and assigning it the result of a GET request to the URL we just created.
4. We are creating a variable called soup and assigning it the result of parsing the response variable using the BeautifulSoup library.
5. We are creating a variable called spans and assigning it the result of a search for all elements with the class “_class_here”.
6. We are looping through each span in the spans variable.
7. We are printing the text of each span.