Settings when using Python 3 requests and Beautiful Soup with crostini on Chromebook

Introduction

I tried scraping with Python3 before (Scraping books borrowed from the library using Python3 and BeautifulSoup --Qiita), but the environment changed and I tried again. It didn't work. After changing the settings, it worked, so leave a note at that time.

Environment

Google Chrome OS
Version 80.0.3987.89 (Official Build) beta (64-bit)
$ python3 --version
Python 3.5.3
$ sudo apt-get install python3-pip
$ pip3 --version
pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.5)
$ sudo apt-get install python3-bs4
$ sudo apt-get install python3-requests

$ pip3 list
beautifulsoup4 (4.5.3)
requests (2.12.4)

Referenced site ↓ Supports requests from Python 3.4 or later --Qiita

What I tried

I get an error when I run it normally.

$ python3 scrape.py 
request
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/urllib3/util/ssl_.py", line 308, in ssl_wrap_socket
    context.load_verify_locations(ca_certs, ca_cert_dir)
ssl.SSLError: unknown error (_ssl.c:3172)

(abridgement)

After searching, this site was a hit. Python requests library can't make HTTPS connections (was: Apache certbot error) - Help - Let's Encrypt Community Support

I tried the command written here in `Solved by:`.

$ cat /etc/ssl/certs/ca-certificates.crt
$ sudo update-ca-certificates
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
$ cat /etc/ssl/certs/ca-certificates.crt 
-----BEGIN CERTIFICATE-----
(abridgement)
-----END CERTIFICATE-----

After this, I ran it again and it worked. It seems that the CA certificate was not included. Is it a public key? It seems that the default is not included when launching a virtual environment by yourself. I didn't like it. I'm not very good at this. For the time being, I'm glad I moved.

Reference site ↓ Ubuntu allows you to install CA certificates with the ca-certificates package-Hidamari sockets won't break What is a Certificate Authority (CA)? | GMO GlobalSign [Official]

Recommended Posts

Settings when using Python 3 requests and Beautiful Soup with crostini on Chromebook
Scraping with Python and Beautiful Soup
Initial settings for using Python3.8 and pip on CentOS8
Troublesome story when using Python3 with VScode on ubuntu
Automate Chrome with Python and Selenium on your Chromebook
IP spoof using tor on macOS and check with python
Try scraping with Python + Beautiful Soup
A memorandum when using beautiful soup
Notes on using rstrip with python.
When using MeCab with virtualenv python
Precautions when using six with Python 2.5
Error and solution when installing python3 with homebrew on mac (catalina 10.15)
[Python] Error and solution memo when using venv with pyenv + anaconda
Using Python and MeCab with Azure Databricks
A memo with Python2.7 and Python3 on CentOS
[Python] Scraping a table using Beautiful Soup
I'm using tox and Python 3.3 with Travis-CI
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
Three things I was addicted to when using Python and MySQL with Docker
[Python] How to save images on the Web at once with Beautiful Soup
What are you using when testing with Python?
I tried various things with Python: scraping (Beautiful Soup + Selenium + PhantomJS) and morphological analysis.
Precautions when using sqlite3 on macOS Sierra (10.12) with multiprocessing
Notes on HDR and RAW image processing with Python
Initial settings when using the foursquare API in python
Install selenium on Mac and try it with python
Findings when accelerating numerical calculations with Python and Numba
Automatic follow on Twitter with python and selenium! (RPA)
Check types_map when using mimetypes on AWS Lambda (Python)
Get comments on youtube Live with [python] and [pytchat]!
Register a ticket with redmine API using python requests
Ubuntu 20.04 on raspberry pi 4 with OpenCV and use with python
Email hipchat with postfix, fluentd and python on Azure
[Python] Webcam frame size and FPS settings with OpenCV
[Python] Delete by specifying a tag with Beautiful Soup
Automated testing method combining Beautiful Soup and Selenium (Python)
Minimum memo when using Python on Mac (pyenv edition)
Minimum notes when using Python on Mac (Homebrew edition)
My Beautiful Soup (Python)
Retry with python requests
Scraping with Beautiful Soup
Get the matched string with a regular expression and reuse it when replacing on Python3
[Raspberry Pi] Scraping of web pages that cannot be obtained with python requests + Beautiful Soup
Settings when developing App Engine / Python apps with VS Code
Building a Python environment on a Mac and using Jupyter lab
Test Python with Miniconda on OS X and Linux with travis-ci
Using Python with SPSS Modeler extension nodes ① Setup and visualization
Serial communication control with python and I2C communication (using USBGPIO8 device)
Things to keep in mind when using Python with AtCoder
Machine learning environment settings based on Python 3 on Mac (coexistence with Python 2)
Notes on deploying pyenv with Homebrew and managing Python versions
Things to keep in mind when using cgi with python.
Serial communication control with python and SPI communication (using USBGPIO8 device)
This and that for using Step Functions with CDK + Python
[Python] How to scrape a local html file and output it as CSV using Beautiful Soup
I tried using "Asciichart Py" which can draw a beautiful graph on the console with Python.
Programming with Python and Tkinter
Save images using python3 requests
When using optparse with iPython
Python and hardware-Using RS232C with Python-
[S3] CRUD with S3 using Python [Python]