****************************************************************************************************
_ _ ____
___ | |__ __ _| |__ _ _ / __ \ _ __ ___ __ _ _ __ ___
/ _ \| '_ \ / _` | '_ \| | | |/ / _` | '_ ` _ \ / _` | '__/ __|
| (_) | |_) | (_| | |_) | |_| | | (_| | | | | | | (_| | | \__ \
\___/|_.__/ \__,_|_.__/ \__, |\ \__,_|_| |_| |_|\__,_|_| |___/
|___/ \____/
美图录爬虫
Verson: 21.6.15
Blog: http://www.h4ck.org.cn
****************************************************************************************************
****************************************************************************************************
[*] 2021-06-16 21:00:11 CAT: 开始分析分类信息......
[*] 2021-06-16 21:00:11 泳装: http://www.meitulu.cn/t/yongzhuang/
[*] 2021-06-16 21:00:11 可爱: http://www.meitulu.cn/t/keai/
[*] 2021-06-16 21:00:11 日本美女: http://www.meitulu.cn/t/ribenmeinv/
BeautifulSoup4 中文乱码
BeautifulSoup4解析页面的时候发现有一部分内容是乱码,刚开始还以为是pycharm的问题,后来发现可能问题不是出在pycharm上,因为普通的print打印的中文是没有问题的。测试代码如下:
def proxy_get(url):
if is_use_proxy:
socks.set_default_proxy(socks.SOCKS5, PROXY_HOST, PROXY_PORT)
socket.socket = socks.socksocket
req = requests.get(url, headers=HEADERS)
return req.text
def get_sub_pages_test(url):
'''
http://www.meitulu.cn/t/shishen/
:param url:
:return:
'''
bs = BeautifulSoup(proxy_get(url), "html.parser")
boxes = bs.find('div', class_='boxs')
lis = boxes.find_all('li')
log_text('PAGE', '开始分析页面链接', is_begin=True)
for l in lis:
p = l.find('p', class_='p_title')
print( p.text)









