参考文章:
Python和js实现逆向之加密参数破解_js btoa python_biyezuopinvip的博客-CSDN博客
JS逆向——借助playwright实现逆向_lishuangbo0123的博客-CSDN博客
简单方便的 JavaScript 逆向辅助模拟方法_token
自己整理的代码
from playwright.sync_api import sync_playwright
import time
import requests
def get_token1(offset):
result = page.evaluate('''()=>{
return window.encrypt("%s","%s")
}''' % ( '/api/movie', offset))
#print(result)
return result
def get_token(params):
result = page.evaluate(
'()=>{return window.encrypt("%s")}' % params)
print(result)
return result
BASE_URL = 'https://spa6.scrape.center'
INDEX_URL = BASE_URL + '/api/movie?limit={limit}&offset={offset}&token={token}'
MAX_PAGE = 2
LIMIT = 10
browser = sync_playwright().start().chromium.launch()
page = browser.new_page()
page.route('**/js/chunk-19c920f8.c3a1129d.js', lambda route: route.fulfill(path='./chunk.js'))
#print(BASE_URL)
page.goto(BASE_URL)
#page.wait_for_load_state('networkidle')
print(page.title())
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36',
'Connection':'keep-alive',
#'sec-ch-ua':'"Chromium";v="21", " Not;A Brand";v="99"',
'Accept':'application/json, text/plain, */*',
'sec-ch-ua-mobile':'?0',
#'sec-ch-ua-platform':'"Windows"',
'Sec-Fetch-Site':'same-origin',
'Sec-Fetch-Mode':'cors',
'Sec-Fetch-Dest':'empty',
'Referer':'https://spa6.scrape.center/',
'Host':'spa6.scrape.center',
'Accept-Language':'zh-CN,zh;q=0.9'
}
for i in range(MAX_PAGE):
offset = i * LIMIT
token = get_token(offset)
index_url = INDEX_URL.format(limit=LIMIT, offset=offset, token=token)
print(index_url)
#response = requests.get(index_url)
response = requests.get(index_url, headers=headers)
print( 'response', response.json)
#print(response)
结果
然并卵,虽然解密了,但是还是不行。不能返回json。response 还是被服务器返回401认证信息,看上去解密出来的token不被服务器识别。试了2个文章中的get_token1(),get_token(),都不行。文章来源:https://www.toymoban.com/news/detail-554401.html
文章来源地址https://www.toymoban.com/news/detail-554401.html
到了这里,关于python爬虫之playWright解密传参的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!