Fix Python – Scraping: SSL: CERTIFICATE_VERIFY_FAILED error for

I’m practicing the code from ‘Web Scraping with Python’, and I keep having this certificate problem:
from urllib.request import urlopen
from bs4 import BeautifulSoup
import re

pages = set()
def getLinks(pageUrl):
global pages
html = urlopen(“”+pageUrl)
bsObj = BeautifulSoup(html)
for link in bsObj.findAll(….

Fix Python – UnicodeEncodeError: ‘charmap’ codec can’t encode characters

I’m trying to scrape a website, but it gives me an error.
I’m using the following code:
import urllib.request
from bs4 import BeautifulSoup

get = urllib.request.urlopen(“”)
html =

soup = BeautifulSoup(html)


And I’m getting the following error:
File “C:\Python34\lib\encodings\”, line 19, i….

Fix Python – How to find elements by class

I’m having trouble parsing HTML elements with “class” attribute using Beautifulsoup. The code looks like this
soup = BeautifulSoup(sdata)
mydivs = soup.findAll(‘div’)
for div in mydivs:
if (div[“class”] == “stylelistrow”):
print div

I get an error on the same line “after” the script finishes.
File “./”, line 130, i….

Fix Python – UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xa0′ in position 20: ordinal not in range(128)

I’m having problems dealing with unicode characters from text fetched from different web pages (on different sites). I am using BeautifulSoup.
The problem is that the error is not always reproducible; it sometimes works with some pages, and sometimes, it barfs by throwing a UnicodeEncodeError. I have tried just about everything I can think of, an….