我正在做一个简单的项目,以提高Python的水平。我正在使用请求库获取“ https://www.instagram.com/graphql/query/?query_hash=58712303d941c6855d4e888c5f0cd22f&variables=%7B%22id%22%3A%2225025320%22%2C%22first%22%3A24%7D ”,这是在Instagram的关注对象(https://www.instagram.com/instagram/following/)上单击关注对象时加载的关注对象的前x个。我的问题是,如何解析以下所有内容?我尝试在线搜索,但找不到任何能证明如何连续获取下一个query_hash url的结果。这是我当前的代码:# Library importsimport requestsimport jsonimport time# VariablesLOGIN_URL = 'https://www.instagram.com/accounts/login/ajax/'REFERER_URL = 'https://www.instagram.com/accounts/login/'USER_AGENT = 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1'USERNAME = 'username'PASSWD = 'password'IGQ = r"https://www.instagram.com/graphql/query/?query_hash=58712303d941c6855d4e888c5f0cd22f&variables=%7B%22id%22%3A%2225025320%22%2C%22first%22%3A24%7D"# Session variablessession = requests.Session()req = session.get(LOGIN_URL)session.headers = {'user-agent': USER_AGENT}session.headers.update({'Referer': REFERER_URL})session.headers = {'user-agent': USER_AGENT}session.headers.update({'x-csrftoken': req.cookies['csrftoken']})login_data = {'username': USERNAME, 'password': PASSWD}login = session.post(LOGIN_URL, data=login_data, allow_redirects=True)session.headers.update({'x-csrftoken': login.cookies['csrftoken']})、目前,我可以成功解析出前x个跟随项,但不确定如何解析其余的跟随项。在chrome开发工具上,滚动时的下一个请求是:https : //www.instagram.com/graphql/query/?query_hash=58712303d941c6855d4e888c5f0cd22f&variables=% 7B%22id%22%3A%2225025320%22%2C% 22first%22% 3A12%2C%22after%22%3A%22AQB-48qzOZue7n4BHPi7FETk2TQnrPl5LiWJKl2nsPCUkLcralRpeTo6F3zQze71zjKh7iDypwv4yxR6OOyHwYj-r1hU5M6P
添加回答
举报
0/150
提交
取消