# 百度贴吧分页爬取练习 import urllib.request # 请求库 import urllib.parse # 解析 import random # 随即库 # 封装三个请求头,由于防爬 headers = [{"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.163 Safari/535.1"}, {"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW6