0

我正在尝试从我正在编写的程序中以编程方式访问 XML 格式的 NOAA 每日潮汐预测数据(即每天的高潮和低潮时间)。数据可从 NOAA 网站免费获得。问题是似乎没有用于获取 XML 数据的 URL。相反,在我看来,它就像需要单击一个表单按钮,该按钮又运行一些下载 XML 文件的 JavaScript。无论如何,是否可以从 WGET 或 CURL 命令访问每日 xml 数据?

例如潮汐数据的 URL 是:NOAA URL

我尝试以编程方式下载的文件可通过Download: XML右侧的按钮访问。

4

1 回答 1

1

The form named "dataform" is made to open in a new window due to the target="_blank" attribute.

If you go to that page in Chrome, and open Developer Tools, you can remove the target="_blank" attribute. Then click the "XML" button again and you will see the call in the network tab.

Here is the call in cURL:

curl 'https://tidesandcurrents.noaa.gov/noaatidepredictions/NOAATidesFacade.jsp?datatype=XML&Stationid=9414275&text=datafiles%252F9414275%252F11022017%252F725%252F&imagename=images%2F9414275%2F11022017%2F725%2F9414275_2017-02-12.gif&bdate=20170211&timelength=daily&timeZone=2&dataUnits=1&interval=&edate=20170212&StationName=Ocean+Beach%2C+outer+coast&Stationid_=9414275&state=CA&primary=Subordinate&datum=MLLW&timeUnits=2&ReferenceStationName=San+Francisco&ReferenceStation=9414290&HeightOffsetLow=%2B0.00&HeightOffsetHigh=%2B0.10&TimeOffsetLow=-35&TimeOffsetHigh=-49&pageview=dayly&print_download=true&Threshold=&thresholdvalue=' -H 'Pragma: no-cache' -H 'Accept-Encoding: gzip, deflate, sdch, br' -H 'Accept-Language: en-US,en;q=0.8' -H 'Upgrade-Insecure-Requests: 1' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' -H 'Referer: https://tidesandcurrents.noaa.gov/noaatidepredictions/NOAATidesFacade.jsp?Stationid=9414275' -H 'Cookie: JSESSIONID=04E346F2DBB84B570709549D8C9B53A3; fsr.r=%7B%22d%22%3A90%2C%22i%22%3A%22de358f8-93151566-93f1-ff56-3e6a0%22%2C%22e%22%3A1487454627727%7D; SRVNAME=tc1; __utmt_GSA_CP1=1; __utmt_GSA_CP2=1; __utma=226417439.2089781402.1486849149.1486849149.1486849149.1; __utmb=226417439.31.10.1486849149; __utmc=226417439; __utmz=226417439.1486849149.1.1.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=(not%20provided); fsr.s=%7B%22v2%22%3A-2%2C%22v1%22%3A1%2C%22rid%22%3A%22de358f8-93151566-93f1-ff56-3e6a0%22%2C%22ru%22%3A%22https%3A%2F%2Fwww.google.com%2F%22%2C%22r%22%3A%22www.google.com%22%2C%22st%22%3A%22%22%2C%22to%22%3A5%2C%22c%22%3A%22https%3A%2F%2Ftidesandcurrents.noaa.gov%2Fnoaatidepredictions%2FNOAATidesFacade.jsp%22%2C%22pv%22%3A16%2C%22lc%22%3A%7B%22d0%22%3A%7B%22v%22%3A16%2C%22s%22%3Atrue%7D%7D%2C%22cd%22%3A0%2C%22sd%22%3A0%2C%22f%22%3A1486851107122%2C%22l%22%3A%22en%22%2C%22i%22%3A-1%7D' -H 'Connection: keep-alive' -H 'Cache-Control: no-cache' --compressed
于 2017-02-11T22:33:31.570 回答