qq空间跳过访问权限
时间: 2024-06-13 20:08:56 浏览: 64
根据引用[1]和引用的内容,我们可以得知,如果QQ空间设置了权限,我们是无法直接访问该空间的。但是,我们可以通过模拟登录的方式来获取该空间的内容。具体步骤如下:
1.使用Selenium模拟登录QQ空间,获取登录后的cookie信息。
```python
from selenium import webdriver
# 模拟登录QQ空间
driver = webdriver.Chrome()
driver.get('https://qzone.qq.com/')
driver.switch_to.frame('login_frame')
driver.find_element_by_id('switcher_plogin').click()
driver.find_element_by_id('u').send_keys('你的QQ号')
driver.find_element_by_id('p').send_keys('你的QQ密码')
driver.find_element_by_id('login_button').click()
# 获取cookie信息
cookie = driver.get_cookies()
driver.quit()
```
2.使用获取到的cookie信息访问该空间的接口,获取该空间的内容。
```python
import requests
# 构造请求头
headers = {
'Referer': 'https://user.qzone.qq.com/你的QQ号',
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3'
}
# 构造请求参数
params = {
'uin': '你的QQ号',
'ftype': '0',
'sort': '0',
'pos': '0',
'num': '20',
'replynum': '100',
'g_tk': 'cookie中的g_tk值',
'callback': '_preloadCallback',
'code_version': '1',
'format': 'jsonp',
'need_private_comment': '1'
}
# 发送请求
response = requests.get('https://user.qzone.qq.com/proxy/domain/taotao.qq.com/cgi-bin/emotion_cgi_msglist_v6', headers=headers, params=params, cookies=cookie)
# 获取响应内容
content = response.content.decode('utf-8')
print(content)
```
需要注意的是,该方法只适用于获取自己的QQ空间内容,如果要获取别人的QQ空间内容,需要先添加对方为好友,并获取对方的cookie信息。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![application/x-zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)