第2章 数据抓取
2.1 beautifulsoup
常见操作:

url='http://example.python-scraping.com'
import requests
from bs4 import BeautifulSoup
resp=requests.get(url)
soup=BeautifulSoup(resp.text,'html.parser')
soup.html
2.2 re表达式
2.2.1在使用re模块时,通常对模式字符串添加r防止转义

2.2.3 re的常见功能函数

2.2.3.1 re.search()

re模块的其他方法同理
re以及bs4的使用
打个比方:
有人给你一个地址要你去办事,bs4就是告诉你这个地址在哪个省份,哪个城市,街道等;而re则是更具体的告诉你这个地址所在的小区,楼号,门牌号
网友评论