摘要:
import requests from lxml import etree # 导入xpath headers = { 'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Ge 阅读全文
posted @ 2021-05-07 17:31
映辉
阅读(122)
评论(0)
推荐(0)
摘要:
1 - 导入模块 from bs4 import BeautifulSoup 2 - 创建对象 fp = open('./test.html','r',encoding='utf-8') soup = BeautifulSoup(fp,'lxml') 3 - 定位 (1)标签定位: 1)div_ta 阅读全文
posted @ 2021-05-07 17:29
映辉
阅读(304)
评论(0)
推荐(0)
摘要:
1 - 安装和导入 pip install requests import requests 2 - requsts的请求方法 requests.get('https://www.baidu.com/') # GET请求: 请求获取url位置的资源 requests.post('https://ww 阅读全文
posted @ 2021-05-07 17:24
映辉
阅读(154)
评论(0)
推荐(0)
摘要:
学习前准备:导入re模块 import re 一、re的核心函数 1 - re.compile(pattern[, flags]) 编译正则表达式,速度快 2 - re.match(pattern, string, flags=0) 只从字符串最开始进行匹配,只返回一个结果 3 - re.searc 阅读全文
posted @ 2021-05-07 17:08
映辉
阅读(79)
评论(0)
推荐(0)
摘要:
1 - 安装前准备 yum -y groupinstall "Development tools" yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-dev 阅读全文
posted @ 2021-05-07 16:57
映辉
阅读(62)
评论(0)
推荐(0)
摘要:
环境: Windows Server 2008 R2 标准版 1、安装python运行环境(省略) 2、安装Django pip install Django==3.1.5 # 不写版本号也可以 3、创建Django项目 django-admin startproject mysite 4、创建AP 阅读全文
posted @ 2021-05-07 16:07
映辉
阅读(70)
评论(0)
推荐(0)
摘要:
1. 模块安装 pip install django-contrib-comments 2. 注册APP INSTALLED_APP=( #..., 'django_comments', 'django.contrib.sites', ) SITE_ID = 1 #需要设置此配置 3. 更新数据库 阅读全文
posted @ 2021-05-07 15:18
映辉
阅读(223)
评论(0)
推荐(0)
摘要:
1.视图views.py from django.core.paginator import Paginator, PageNotAnInteger, EmptyPage def index(request): all = Blog.objects.all() # 获取全部数据的对象 paginat 阅读全文
posted @ 2021-05-07 14:10
映辉
阅读(151)
评论(0)
推荐(0)
摘要:
1.生成requirements.txt pip freeze > requirements.txt 2.使用requirements.txt pip install -r requirements.txt 阅读全文
posted @ 2021-05-07 13:50
映辉
阅读(299)
评论(0)
推荐(0)

浙公网安备 33010602011771号