self_example/Spider/Chapter07_动态渲染页面爬取/字体反爬案例分析与爬取实战/main2.py

20 lines
488 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#-*- encoding:utf-8 -*-
'''
@Author : dingjiawen
@Date : 2023/12/7 20:20
@Usage :
@Desc :尝试解析对应的css源文件来获取对应的我们想要的
'''
import re
import requests
url = 'https://antispider4.scrape.center/css/app.654ba59e.css'
response = requests.get(url)
pattern = re.compile('.icon-(.*?):before\{content:"(.*?)"\}')
results = re.findall(pattern, response.text)
icon_map = {item[0]: item[1] for item in results}
print(icon_map['789'])
print(icon_map['437'])