I am trying to scrape "167" (top right) from the following website: https://www.goodfirms.co/billing-invoicing-software/.
I can manage to get all of the text, but I'm just trying to get the numbers, and I am not sure on how to isolate it. Would someone be able to help me?
Code:
from bs4 import BeautifulSoup as bs
import requests
import requests_random_user_agent
s = requests.Session()
user_agent = s.headers['User-Agent']
headers = {
'accept': '*/*',
'accept-language': 'en-GB,en-US;q=0.9,en;q=0.8,es;q=0.7,ru;q=0.6',
'referer': 'https://www.google.com/',
'connection': 'Keep-alive',
'user-agent': user_agent,
}
response = requests.get('https://www.goodfirms.co/billing-invoicing-software/', headers=headers)
soup = bs(response.content, 'lxml')
test = soup.find("section", class_="section-breadcrumb blog-breadcrumb overflow").text
print(test)
Output:
Home >
Billing and Invoicing Software
167 Softwares | Last updated: Jul 31, 2022
Desired output:
167
Thanks!
CodePudding user response:
The number Prints:167
is located under tag with class lang-py prettyprint-override">
import requests
from bs4 import BeautifulSoup
url = "https://www.goodfirms.co/billing-invoicing-software/"
soup = BeautifulSoup(requests.get(url).content, "html.parser")
num = soup.select_one(".last_update strong")
print(num.text)
167