前言
大眾點評擁有大量高質量評論資訊、種草資訊,同時也有非常嚴格的反扒機制,
今天我們一起使用 Python破解大眾點評字體加密,獲取極具商業價值的資訊,
本文知識點:
- requests 的使用
- xpath 的使用
- svg 字體處理
開發環境:
- 解釋器: Python 3.6.5 | Anaconda, Inc.
- 編輯器: pycharm 專業版
目標地址
http://www.dianping.com/shop/130096343/review_all
代碼
匯入工具
import requests
import re
獲取資料
# ctrl + r
headers = {
"Cookie": "加上自己的cookie",
"Host": "www.dianping.com",
"Referer": "http://www.dianping.com/shop/130096343/review_all",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36",
}
response = requests.get('http://www.dianping.com/shop/130096343/review_all', headers=headers)
# http://www.dianping.com/shop/130096343/review_all
print(response.text)
with open('01 網頁資料_加密.html', mode='w', encoding='utf-8') as f:
f.write(response.text)
css_url = re.findall('<link rel="stylesheet" type="text/css" href="https://www.cnblogs.com/hhh188764/p/(//s3plus.meituan.*?)">', response.text)
css_url = 'http:' + css_url[0]
css_response = requests.get(css_url)
with open('02 css樣式.css', mode='w', encoding='utf-8') as f:
f.write(css_response.text)
print(css_response.text)
svg_url = re.findall(r'svgmtsi\[class\^="eb"\].*?background-image: url\((.*?)\);', css_response.text)
svg_url = 'http:' + svg_url[0]
svg_response = requests.get(svg_url)
with open('03 svgy隱射表.svg', mode='w', encoding='utf-8') as f:
f.write(svg_response.text)
print(svg_url)
詳細專案視頻講解地址
https://www.bilibili.com/video/BV1uC4y1t78d/
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/14008.html
標籤:Python
下一篇:求助
