爬虫(静态页面)

今天所学:爬虫
其实这个东西搞了好久
材料:python chrome BeautifulSoup requests
过程:
1:取出库
2:请求
3:用beautiful来处理数据

难点
1:编码问题
妈蛋,这个以后一定要全部明白
常见解决方式:
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030')


# -*- coding: utf-8 -*-

f=open('nee.txt','w',encoding='utf-8')

content = content.decode('gbk', 'ignore') #将gbk编码转为unicode编码
content = content.encode('utf-8', 'ignore') #将unicode编码转为utf-8编码
2:BeautifulSoup的使用
嗯今天就用了BeautifulSoup() , .select(),.text
.select(表格(h1/a))(#id)(.class 类)[字典属性]
以上常用方法
我擦,学了一天总结只有这么点。。。
ps:明天开始分布式爬虫

转载于:https://www.cnblogs.com/17storyteller/p/6826587.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值