Oct-14-2022, 06:40 AM
#!/usr/bin/python3 from bs4 import BeautifulSoup import requests import lxml import csv URL = "https://sandiego.craigslist.org/search/sof" page = requests.get(URL) soup = BeautifulSoup(page.content, "lxml") # h3 tag job_heading = [] for a in soup.find_all("h3"): job_heading.append(a.string.strip()) # location time = [] for b in soup.find_all("time"): time.append(b.string.strip()) with open('output.csv', 'w') as file: writer = csv.writer(file, delimiter=',') writer.writerow(["job_heading", "time"]) for i in range(25): writer.writerow([ job_heading[i], time[i] ])please, help me remove this error so after running this script, there is no "AtributeError: 'NoneType' object has no attribute 'strip'" thanks.