猿人学第7题-字体反爬

This commit is contained in:
luzhisheng 2022-05-09 23:04:16 +08:00
parent a9dcd36201
commit e8ee2cb087
4 changed files with 480 additions and 0 deletions

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

View File

@ -0,0 +1,45 @@
from urllib.parse import urlparse
import requests
import time
import json
import base64
class App(object):
def __init__(self):
pass
def get_html(self, m, page):
Headers = {
"user-agent": "yuanrenxue.project",
"cookie": m
}
url = f"https://match.yuanrenxue.com/api/match/7?page={page}"
print(url)
req = requests.get(url=url, headers=Headers)
return json.loads(req.text)
def with_ttf(self, woff):
b64_code = woff
with open('font.ttf', 'wb') as f:
f.write(base64.decodebytes(b64_code.encode()))
def run(self):
data_sum = 0
for page in range(1, 6):
res = self.get_html("", page)
woff = res.get('woff')
self.with_ttf(woff)
data_list = res.get('data')
for data in data_list:
print(data.get('value'))
# data_sum += data.get('value')
time.sleep(1)
print(data_sum)
if __name__ == '__main__':
app = App()
app.run()