Help with web scraping code


trying to scrape google search results on what year IBM will be net zero by. Instead of receiving multiple results. To make things easier, I’ve applied an ‘if’ function; if the data that is found has ‘by 20…’ (eg. by 2030), print ‘yes’, else: print ‘no’.
However, the scraper says no to every data which is found, even data that says ‘…by 2030’.

Anyone able to help me out please?
I’ve pasted my code below…

Import the beautifulsoup

and request libraries of python.

import requests
import bs4
import math
import csv

Make two strings with default google search URL’ and

our customized search keyword.

Concatenate them

text = “ibm+carbon+emissions+net+zero”
url = ‘’ + text

Fetch the URL data using requests.get(url),

store it in a variable, request_result.

request_result = requests.get(url)

Creating soup from the fetched request

soup = bs4.BeautifulSoup(request_result.text,

soup.find.all( h3 ) to grab

all major headings of our search result,

heading_object = soup.find_all(‘span’)

Iterate through the object

and print it as a string.

if ‘IBM’ in heading_object:
for info in heading_object: