I started learning Python recently using "The New Boston's" videos on YouTube. Everything was going great until I got to his tutorial of making a simple web crawler.
While I understood it without any problem, when I run the code I get errors all seemingly based around "SSL: CERTIFICATE_VERIFY_FAILED."
I've been searching for an answer since last night, trying to figure out how to fix it. It seems no one else in the comments on the video or on his website are having the same problem as me and even using someone else’s code from his website I get the same results.
Below is the code from the website, as it's giving me the same error:
import requests
from bs4 import BeautifulSoup
def trade_spider(max_pages):
page = 1
while page <= max_pages:
url = "https://www.thenewboston.com/forum/category.php?id=15&orderby=recent&page=" + str(page) #this is page of popular posts
source_code = requests.get(url)
# Just get the code, no headers or anything
plain_text = source_code.text
# Beautiful Soup objects can be sorted through easy
for link in soup.findAll('a', {'class': 'index_singleListingTitles'}): # All links, which contains "" class='index_singleListingTitles' "" in it.
href = "https://www.thenewboston.com/" + link.get('href')
title = link.string # Just the text, not the HTML content
print(href)
print(title)
#get_single_item_data(href)
page += 1
trade_spider(1)
The full error is:
ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)