• BeautifulSoup基本用法

    2021-11-07 浏览:608
    安装 pip3 install beautifulsoup4 引入 # HTTP 请求库 import urllib.request, urllib.error from bs4 import BeautifulSoup # 解决自签证书错误问题 import ssl 获取页面 headers = { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36' } context = ssl._create_unverified_context() req = urllib.request.Request(url='https:/... 展开全文
  • SQLAlchemy基本用法

    2021-11-07 浏览:526
    SQLAlchemy是Python中一个通过 ORM 操作数据库的框架 安装 pip3 install sqlalchemy 引入 from sqlalchemy import create_engine, or_ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, DateTime from sqlalchemy.orm import sessionmaker 连接数据库 举例 sqlite3 Base = declarative_base() engine = create_engine('sqlite:///main.db', encoding="utf-8", echo... 展开全文