Python爬虫,爬虫访问网站时遇到415. UnsupportedMediaType错误,运行结果为空

问题遇到的现象和发生背景

初学python爬虫,练习爬取1~200页文章,不知道是不是因为页面的url找错了,运行结果啥也没有。

问题相关代码,请勿粘贴截图

#导入必要模块
import requests
from bs4 import BeautifulSoup
import re

#创建idx 1~200页
for idx in range(200):
print("#"*30,idx+1)

#网站url
url = " https://www.cnblogs.com/AggSite/AggSitePostList"

#通过分析网站源码可知每页的url信息
data = {"CategoryType":"SiteHome",
        "ParentCategoryId":0,
        "CategoryId":808,
        "PageIndex":idx+1,
        "TotalPostCount":4000,
        "ItemListActionName":"AggSitePostList"}

#requests模块获取网页信息
r = requests.get(url,data=data)

#判断网页状态码
# if r.status_code != 200:
#     raise Exception()

#bs4模块创建对象
soup = BeautifulSoup(r.text,"html.parser")

#指定class获取指定信息
post_items = soup.find_all("article",class_="post-item")
for post_item in post_items:
    link = post_item.find("a",class_="post-item-title")
    print(link["href"],link.get_text())
运行结果及报错内容

img

我的解答思路和尝试过的方法

打印了r.text发现无法访问https://www.cnblogs.com/AggSite/AggSitePostList,访问结果时415. UnsupportedMediaType
不知道怎么找到正确的url

我想要达到的结果

爬出1-200页的文章

img

你的请求头呢? 你的翻页循环加入参数呢? 这些你都没写

url改这个试试

url = "https://www.cnblogs.com/"

```