29 lines
736 B
Python
29 lines
736 B
Python
# -*- encoding:utf-8 -*-
|
|
|
|
'''
|
|
@Author : dingjiawen
|
|
@Date : 2024/03/26 13:08
|
|
@Usage :
|
|
@Desc :使用wasmer库完成爬取https://spa14.scrape.center/
|
|
'''
|
|
|
|
import time
|
|
from wasmer import engine, Store, Module, Instance
|
|
from wasmer_compiler_cranelift import Compiler
|
|
import requests
|
|
|
|
baseurl = 'https://spa14.scrape.center/api/movie/?limit={limit}&offset={offset}&sign={sign}'
|
|
MAX_PAGE = 10
|
|
limit = 10
|
|
|
|
store = Store(engine.JIT(Compiler))
|
|
module = Module(store, open('Wasm.wasm', 'rb').read())
|
|
instance = Instance(module)
|
|
|
|
|
|
for i in range(MAX_PAGE):
|
|
offset = i * limit
|
|
sign = instance.exports.encrypt(offset, int(time.time()))
|
|
result = requests.get(baseurl.format(limit=limit, offset=offset, sign=sign))
|
|
print(result.text)
|