cookie的作用:模拟登录/反反爬
referer:记录是从哪一个页面跳转过来的
Query String Paraments:参数
Form data:携带的参数有哪些
urrlib模块
urllib.parse
{中文转16进制}: urllib.parse.urlopen{‘wd’:’老师’} urllib.parse.quote()
urllib.parse.unquote()十六进制转码
requests模块
response.content:返回字节流
response.content.decode(‘utf-8’)
response.text:返回时字符串
response.encoding = ‘utf-8’
代理ip
浏览器:输入ipip.net外网
数据解析
正则
使用:import re
re.match(正则表达式,要匹配的字符串) ,匹配成功返回match对象,匹配失败,返回None
compile:根据包含正则表达式的字符串创建模式对象
search:只匹配一个字符串
findall:找到多个数据,存放于列表中
re分组功能:.*?
csv读写模式
impor csv
写:
1.序列写入
数据要有对应的表头;创建write对象(csv.write())
2.字典形式写入
xpath
bs4
1.pip install bs4
2.from bs4 import BeautifulSoup
3.创建对象:soup = BeautifulSoup(tag,lxml)
4.根据需求调用方法(find():返回搜索到第一条数据 find_all():以列表的形式返回所有的搜索到的标签数据
5.遍历文档树
string:获取标签的内容
strings:返回多个标签内容(循环遍历/强制转换)
stripped_strings:可以把多余的空格
