I am trying to scrape data from a website https://animaldiversity.org/accounts/Callithrix%20humilis from the <p>

Viewed 35
1 Answers

To get information about name, habitat from this page, you can use next example:

import requests
from bs4 import BeautifulSoup

url = "https://animaldiversity.org/accounts/Callithrix%20humilis"
soup = BeautifulSoup(requests.get(url).content, "html.parser")

name = soup.select_one("h2.rank-species").find_next(text=True).strip()
vernacular_name = soup.select_one("h2.rank-species > span").get_text(strip=True)
habitat = soup.select_one("h3#habitat + p").get_text(strip=True)

print(name)
print(vernacular_name)
print(habitat)

Prints:

Callithrix humilis
Roosmalens' dwarf marmoset
Roosmalen's dwarf marmosets are found in disturbed primary and secondary terra firme rain forests and terra prestas forests. Roosmalen and Roosmalen explain that terra prestas are soils made by pre-Columbian farmers who mixed "decomposed organic material...and large quantities of charcoal, calcium and phosphates" near bluffs and lakes. At first, it was assumed that they only occur away from human habitations, but it seems they prefer disturbed forest areas near human inhabited areas such as plantations, gardens, and fields.(Roosmalen and Roosmalen, 2003)
Related