主 url 为 this,POST 数据为 [{"target":"nepaltour.info","max_crawl_pages":5}]
,结果为
{version: 0.1.20210519, status_code: 20000, status_message: Ok., time: 0.1509 秒,成本:0.000625,tasks_count:1,tasks_error:0,tasks:[{id:05210936-2757-0216-0000-49826d093722,status_code:20100, status_message:任务已创建,时间:0.0154 秒,成本:0.000625, result_count: 0, 路径: [v3, on_page, task_post], 数据: {api: on_page, 功能:task_post,目标:nepaltour.info,max_crawl_pages:5}, 结果:空}]}。
这是从 POST API 获取的 id:05210936-2757-0216-0000-49826d093722
。现在我们需要来自 here 的目标 url 的摘要,它只给出:
{version: 0.1.20210519, status_code: 20000, status_message: Ok., 时间:0.1142 秒,成本:0,tasks_count:1,tasks_error:0,tasks: [{id: 05210936-2757-0216-0000-49826d093722, status_code: 20000, status_message:好的,时间:0.0470 秒,成本:0,result_count:1, 路径:[v3,on_page,摘要,05210936-2757-0216-0000-49826d093722], 数据:{api:on_page,函数:摘要},结果:[{crawl_progress: in_progress, domain_info: null, page_metrics: null, crawl_status: {max_crawl_pages: 5, pages_in_queue: 1, pages_crawled: 0}}]}]}
最终网址是 this.
print('url $url');
String username = 'adhikaritoban@gmail.com';
String password = '7eda91fd91c15c5e';
String basicAuth =
'Basic ' + base64Encode(utf8.encode('$username:$password'));
print(basicAuth);
final response = await http.get(
Uri.parse(url),
headers: {
"Content-Type": "application/json",
"Authorization": basicAuth,
"Accept": "application/json"
},
);
if(response.statusCode == 200){
final extractedData = json.decode(response.body) as Map<String, dynamic>;
print("extra $extractedData");
final _external =
extractedData['tasks']['result']['page_metrics']['links_external'];
print("ex $_external");
final _internal =
extractedData['tasks']['result']['page_metrics']['links_internal'];
final _duplicateTitle =
extractedData['tasks']['result']['page_metrics']['duplicate_title'];
final _duplicateDescription = extractedData['tasks']['result']['page_metrics']
['duplicate_description'];
final _duplicateContent =
extractedData['tasks']['result']['page_metrics']['duplicate_content'];
final _brokenLinks =
extractedData['tasks']['result']['page_metrics']['broken_links'];
final _brokenResources =
extractedData['tasks']['result']['page_metrics']['broken_resources'];
final _onPageScore =
extractedData['tasks']['result']['page_metrics']['onpage_score'];
print('$_onPageScore');
}else {
print('FireGun');
}