Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
754 B
5
Indexable
search_term = 'Dark-eyed+Junco'  # change this to your desired search term

# build the search URL
url = f'https://www.allaboutbirds.org/news/search/?q={search_term}'

# send a GET request to the search URL
response = requests.get(url, stream=True)

# parse the HTML content of the response using BeautifulSoup
soup = BeautifulSoup(response.content, 'html.parser')
print(soup)
# find all the search result items on the page
search_results = soup.find_all('h2', class_='Species Results')

# print the titles and URLs of the search result items
for result in search_results:
    title = result.find('h2', class_='search-result__title').text.strip()
    url = result.find('a', class_='search-result__link')['href']
    print(f'Title: {title}\nURL: {url}\n')