如何让curl从web下载json?

wgmfuz8q  于 2023-06-23  发布在  其他
关注(0)|答案(1)|浏览(137)

我试图通过curl从web服务器获取数据。我可以直接用浏览器下载数据,如下所示:
https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_alkis?version=2.0.0&outputFormat=application%2Fgeo%2Bjson&typeNames=fis%3As_wfs_alkis&count=100000&service=WFS&request=GetFeature&bbox=392830.5359884375,5818765.207758436,393816.9642084504,5818080.847642038
但当我找到

curl "fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_alkis?version=2.0.0&outputFormat=application%2Fgeo%2Bjson&typeNames=fis%3As_wfs_alkis&count=100000&service=WFS&request=GetFeature&bbox=392830.5359884375,5818765.207758436,393816.9642084504,5818080.847642038" -o test.txt

它只返回一个空文件。我错过了什么?
非常感谢你的帮助!

zazmityj

zazmityj1#

你需要改变一些标题:

curl -A "Mozilla/5.0" -k -L -b cookies.txt -c cookies.txt -o file.json -s 'https://fbinter.stadt-berlin.de/fb/wfs/data/senstadt/s_wfs_alkis?version=2.0.0&outputFormat=application%2Fgeo%2Bjson&typeNames=fis%3As_wfs_alkis&count=100000&service=WFS&request=GetFeature&bbox=392830.5359884375,5818765.207758436,393816.9642084504,5818080.847642038'

相关问题