英文:
how to get curl to download a json from web?
问题
我正在尝试通过curl从Web服务器获取数据。我可以像这样直接使用浏览器下载数据:
但是当我使用curl进行如下操作时,它只返回一个空文件。我漏掉了什么?
谢谢你的帮助!
英文:
i am trying to fetch data from a webserver via curl.
i can download the data directly with a browser like so:
but when i do
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
it just returns an empty file. what am i missing here?
Thanks a lot for help!
答案1
得分: 1
你需要更改一些请求头:
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'
英文:
You need to change some HEADERS:
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'
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论