点击加载后,可以注意到向https://samizdat-graphql.nytimes.com/graphql/v2这个地址发送了一个post请求,返回了一个json格式的内容:{
"data": {
#省略
}, {
"node": {
"__typename": "BodegaResult",
"node": {
"id": "QXJ0aWNsZTpueXQ6Ly9hcnRpY2xlLzdiOTE1YTM4LTg5N2QtNWQ5Yi1hNWJkLTVkOWQ1YzY2NmUxNA==",
"__typename": "Article",
"url": "https://www.nytimes.com/2019/01/28/obituaries/peter-magowan-dead.html",
"uri": "nyt://article/7b915a38-897d-5d9b-a5bd-5d9d5c666e14",
"promotionalHeadline": "Peter Magowan, Giants Fan Turned Giants’ Owner, Is Dead at 76",
"promotionalSummary": "While running Safeway Stores, Mr. Magowan headed a group that bought the team and kept it from moving from San Francisco to Florida.",
#省略
可以发现新的内容就在这里面,知道了流程那就只需要向对应的地址发送一个post请求就行了。需要注意,这里post请求发送的内容是payload,也就是一个json格式:{
"operationName": "SearchRootQuery",
"variables": {
"first": 10,
"sort": "best",
"beginDate": "20190101",
"endDate": "20190131",
"filterQuery": "((section_uri: "nyt://section/91a0dd36-11a8-5a06-9b6e-3a3d2f281894")) AND ((data_type: "article"))",
"sectionFacetFilterQuery": "((data_type: "article"))",
"typeFacetFilterQuery": "((section_uri: "nyt://section/91a0dd36-11a8-5a06-9b6e-3a3d2f281894"))",
"sectionFacetActive": true,
"typeFacetActive": true,
"cursor": "YXJyYXljb25uZWN0aW9uOjk="
},
"extensions": {
"persistedQuery": {
"version": 1,
"sha256Hash": "d632cb222f6a7dd48349d5789975e28fbf7017963fe1ec16fd20fa868b335842"
}
}
}
只需要创建一个对应的嵌套集合,然后json.dump成data就可以了
|