Python爬取网页数据基本步骤:

*
from urllib import request
response = request.urlopen(‘完整的网址’)

*
import requests
import chardet
url = ‘完整的网址’
response = requests.get(url)
response.encoding = chardet.detect(response.content)[‘encoding’]
# 文本
html = response.text

*
selenium (动态加载的 网页,就用这个)
from selenium import webdriver

*
scrapy 框架

----- 提取 内容 ------
一般通过 浏览的控制台,先找 统一结构。然后找父元素
1. 正则表达式
2. beautifulsoup
3. selenium的相关方法
4. xpath

----- 存储 内容 -------
1. txt
2. csv
3. excel
4. mongodb
5. mysql

技术
今日推荐
PPT
阅读数 115
下载桌面版
GitHub
百度网盘(提取码:draw)
Gitee
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:ixiaoyang8@qq.com
QQ群:766591547
关注微信