I hope that you are well. I have tried searching the other threads about my issue, but I have yet to find a solution. Attached below are the screenshots of my work and methods to install the bs4 module, and the error I encounter. I am more than willing to attach more screenshots if required. Here is the command prompt telling me that the installation was successful
import csv
import requests
from bs4 import BeautifulSoup4 as beauti
url = 'https://report.boonecountymo.org/mrcjava/servlet/SH01_MP.I00290s?max_rows=500'
response = requests.get(url, headers={'User-Agent': 'Mozilla/5.0'})
html = response.content
soup = BeautifulSoup(html)
table = soup.find('tbody', attrs={'class': 'stripe'})
list_of_rows = []
for row in table.findAll('tr'):
list_of_cells = []
for cell in row.findAll('td'):
text = cell.text.replace(' ', '')
list_of_cells.append(text)
list_of_rows.append(list_of_cells)
outfile = open("./inmates.csv", "wb")
writer = csv.writer(outfile)
writer.writerow(["Last", "First", "Middle", "Gender", "Race", "Age", "City", "State"])
writer.writerows(list_of_rows)
Below is IDLE giving me the error:
Traceback (most recent call last):
File "C:\Users\aditi\Desktop\webscraper.py", line 3, in <module>
from bs4 import BeautifulSoup4 as beauti
ImportError: cannot import name 'BeautifulSoup4' from 'bs4' (C:\Users\aditi\AppData\Local\Programs\Python\Python38-32\lib\site-packages\bs4\__init__.py)