如何获取令牌当它被JS发送请求生成?

问题描述 投票:0回答:1

我创建了这个网站的脚本:

第一部分(使帐户完成):https://my.shaadi.com/profile-creation/step/1?gtrk=1

不过配置我有一个问题配置文件时,页面被加载JS和令牌使用JS生成的为好。

https://my.shaadi.com/static/js/main.4c82cc30.js这是JS文件:

X-Access-Token: 2a719ecb4cf7a3ef45676834a596bc58|4SH80109362|
X-App-Key: 69c3f1c1ea31d60aa5516a439bb65949cf3f8a1330679fa7ff91fc9a5681b564

这些是2个令牌,我希望得到我想不出获得这些的方法是有可能使用要求做到这一点还是它需要一个无头的浏览器上运行JS(我想这样做纯蟒蛇请求)

python python-requests
1个回答
0
投票

最好/最简单的就是使用硒或dryscrape和BeautifulSoup。

#from bs4 import BeautifulSoup
from selenium import webdriver

client = webdriver.PhantomJS()
#client.get('https://my.shaadi.com/profile-creation/step/1?gtrk=1')
client.get('https://my.shaadi.com/static/js/main.4c82cc30.js')
body = client.page_source

现在,您可以解析机身采用正则表达式或BeautifulSoup

© www.soinside.com 2019 - 2024. All rights reserved.