我创建了这个网站的脚本:
第一部分(使帐户完成):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(我想这样做纯蟒蛇请求)
最好/最简单的就是使用硒或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