![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
python
ccrispy
bebest
展开
-
python04
04 正则固定表 \d : 任何数字 \D : 不是数字 \s : 任何 white space, 如 [\t\n\r\f\v] \S : 不是 white space \w : 任何大小写字母, 数字和 _ [a-zA-Z0-9_] \W : 不是 \w \b : 空白字符 (只在某个字的开头或结尾) \B : 空白字符 (不在某个字的开头或结尾) \\ : 匹配 \ . : 匹配任何字符 (除了 \n) ^ : 匹配开头 $ : 匹配结尾 ? : 前面的字符可有可无 * : 重复零次或多次 + : 重复原创 2020-09-16 16:38:48 · 134 阅读 · 0 评论 -
python03
03 爬取页面内容 1)`import` bs4以及urllib 2)获取url 定义html 3)引入bs4 以html为基础 4)通过bs以lxml进行解析html 5)通过class即css类名以及li标签进行定义month 6)遍历month 获取文本信息.get_text() from bs4 import BeautifulSoup from urllib.request import urlopen html = urlopen("https://mofanpy.com/static/sc原创 2020-09-16 16:07:24 · 70 阅读 · 0 评论 -
python02
02 转自老师总结: 1)选着要爬的网址 (url) 2)使用 python 登录上这个网址 (urlopen等) 3)读取网页信息 (read() 出来) 4)将读取的信息放入 BeautifulSoup 5)使用 BeautifulSoup 选取 tag 信息等 (代替正则表达式) beautifulSoup下载安装 # Python 2+ pip install beautifulsoup4 # Python 3+ pip3 install beautifulsoup4 开始学习使用bs4 由于原创 2020-09-16 15:50:15 · 91 阅读 · 0 评论 -
mofanpy01
01 简易爬源码 使用python登录网站以后打印出源代码 由于老师提供的链接存在中文,read()以后需要进行decode('utf-8')进行中文转换。 from urllib.request import urlopen #如有中文,请decode() html = urlopen("https://mofanpy.com/static/scraping/basic-structure.html").read().decode('utf-8') #获取html进行read(),并且使用decode()原创 2020-09-16 15:35:23 · 126 阅读 · 0 评论 -
python爬数据
import requests from lxml import etree url = "https://q.cnblogs.com/q/106593/" header = {"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"} html = requests.get(url, headers=h原创 2020-09-15 16:31:52 · 63 阅读 · 0 评论