Botify数据导出字段语法错误,求添加特定字段的正确语法
Botify查询添加维度字段失败的语法问题
我用Python结合Botify Query Language拉取网站爬取数据,通过requests.PUT()向Botify发送JSON请求获取爬取值。原本正常运行的请求,在query→dimensions部分添加部分元数据列后,收到了FAILURE响应。
需要确认以下字段添加到JSON的query→dimensions部分的正确语法:
compliant.is_compliantmetadata.robots.noindexhttp_redirect.to.final.path
失败的请求JSON
{ "job_type": "export", "payload": { "username": "myID", "project": "website.com", "export_size": 50, "formatter": "csv", "formatter_config": { "delimiter": ",", "print_delimiter": "False", "print_header": "True", "header_format": "verbose" }, "connector": "direct_download", "extra_config": {}, "query": { "collections": ["crawl.20230515"], "query": { "dimensions": ["url", "crawl.20230515.date_crawled", "crawl.20230515.content_type", "crawl.20230515.http_code", "segments.pagetype.value", "compliant.is_compliant", "metadata.robots.noindex", "http_redirect.to.final.path" ], "metrics": [], "sort": [1] } } } }
收到的错误响应
{'job_id': 1831591, 'job_type': 'export', 'job_url': '/v1/jobs/1831591', 'job_status': 'FAILED', 'results': {'nb_lines': None}, 'date_created': '2023-05-27T17:12:54.074062Z', 'payload': {'query': {'query': {'sort': [1], 'metrics': [], 'dimensions': ['url', 'crawl.20230515.date_crawled', 'crawl.20230515.content_type', 'crawl.20230515.http_code', 'segments.pagetype.value', 'segments.country.value', 'crawl.20230515.is_compliant']}, 'collections': ['crawl.20230515']}, 'export_size': 50, 'connector': 'direct_download', 'formatter': 'csv', 'formatter_config': {'delimiter': ',', 'print_header': True, 'header_format': 'verbose', 'print_delimiter': False}, 'extra_config': {}, 'sort_url_id': False, 'export_job_name': None}, 'user': 'XXXXXXXX', 'metadata': None, 'crawl_date': None}
解决方案
Botify的维度字段需要关联到具体的爬取集合(即你指定的crawl.20230515),你之前的字段缺少了集合前缀,导致识别失败。正确的字段格式应该是:
crawl.20230515.compliant.is_compliantcrawl.20230515.metadata.robots.noindexcrawl.20230515.http_redirect.to.final.path
修改后的dimensions部分如下:
"dimensions": [ "url", "crawl.20230515.date_crawled", "crawl.20230515.content_type", "crawl.20230515.http_code", "segments.pagetype.value", "crawl.20230515.compliant.is_compliant", "crawl.20230515.metadata.robots.noindex", "crawl.20230515.http_redirect.to.final.path" ]
另外注意错误响应里出现了segments.country.value字段,但你的请求中并没有包含该字段,建议检查是否有残留的配置或之前的请求缓存,确保请求中的字段都是你实际需要的。
内容的提问来源于stack exchange,提问作者marie20
相关产品推荐
相关产品推荐

