如何从C#网站上的表中获取数据?

时间:2017-02-07 17:21:28

标签: c#

我阅读了许多主题如何从网站上获取数据等,但我无法找到解决问题的方法。

所以,我试图从这个表中获取数据: http://www.opole.pios.gov.pl:81/dane-pomiarowe/automatyczne/stacja/118/parametry/461/dzienny/07.02.2017

但是每个方法都只给我这样的html代码:

"<!DOCTYPE html>\n<html>\n<head>\n    <meta charset=\"utf-8\">\n    <meta name=\"viewport\"\n          content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no\">\n    <meta name=\"product\" content=\"GIOS WWW\">\n    <meta name=\"description\" content=\"\">\n    <meta name=\"author\" content=\"DAC SYSTEM\">\n                                        <link rel=\"stylesheet\" href=\"/static/core.css?v3\" media=\"screen\" type=\"text/css\"/>\n            \n        <link rel=\"stylesheet\" href=\"/static/browse.css?v3\"/>\n            <link rel=\"stylesheet\"\n          href=\"/static/../compass/stylesheets/styles/pl_OPO.css?v3\"/>\n    <title>WIOŚ Opole - Prezentacja pomiarów</title>\n    <script>\n    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n                (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n            m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n    ga('create', 'UA-72664157-1', 'auto');\n    ga('send', 'pageview');\n\n</script>\n</head>\n<body class=\"metro browse base\">\n<header id=\"top-nav\" class=\"bg-dark\">\n    <div id=\"top-menu\" class=\"navigation-bar dark fixed-top center-content\" data-show=\"hover\">\n        <div class=\"navigation-bar-content container\">\n\n                <a href=\"/\" class=\"element\"><span class=\"icon-home\"></span> STRONA GŁÓWNA</a>\n    <span class=\"element-divider\"></span>\n\n            \n        <ul     class=\"element-menu\">\n                                                                        <li     class=\"first\">\n                        <a class=\"dropdown-toggle\" href=\"#\">Informacje</a>\n    \n                            \n        <ul     class=\"dropdown-menu dark menu_level_1\" data-role=\"dropdown\">\n                                                                        <li     class=\"first\">\n                        <a href=\"/ocena-jakosci-powietrza\" >Ocena jakości powietrza</a>\n    \n                            \n        </li>\n    \n                                        <li    >\n                        <a href=\"/opis-monitorowanych-substancji\" >Opis monitorowanych substancji</a>\n    \n                            \n        </li>\n    \n                                        <li    >\n                        <a href=\"/standardy-jakosci-powietrza\" >Standardy jakości powietrza</a>\n    \n                            \n        </li>\n    \n                                        <li    >\n                        <a href=\"/indeks-jakosci-powietrza\" >Indeks jakości powietrza</a>\n    \n                            \n        </li>\n    \n                                        <li    >\n                        <a href=\"/publikacje\" >Publikacje</a>\n    \n                            \n        </li>\n    \n                                        <li     class=\"last\">\n                        <a href=\"/prognozy\" >Prognozy</a>\n    \n                            \n        </li>\n    \n                \n        </ul>\n    \n        </li>\n    \n                                        <li    >\n                        <a class=\"dropdown-toggle\" href=\"#\">Stacje pomiarowe</a>\n    \n                            \n        <ul     class=\"dropdown-menu dark menu_level_1\" data-role=\"dropdown\">\n                                                                        <li     class=\"first\">\n                        <a href=\"/stacje/aktywne\" >Stacje aktywne</a>\n    \n                            \n        </li>\n    \n                                        <li     class=\"last\">\n                        <a href=\"/stacje/archiwalne\" >Stacje archiwalne</a>\n    \n                            \n        </li>\n    \n                \n        </ul>\n    \n        </li>\n    \n                                        <li    >\n                        <a class=\"dropdown-toggle\" href=\"#\">Dane pomiarowe</a>\n    \n                            \n        <ul     class=\"dropdown-menu dark menu_level_1\" data-role=\"dropdown\">\n                                                                        <li     class=\"first\">\n                        <a href=\"/dane-pomiarowe\" >Dane aktualne</a>\n    \n                            \n        </li>\n    \n                                        <li     class=\"last\">\n                        <a href=\"/archiwalne-dane-pomiarowe\" >Dane archiwalne</a>\n    \n                            \n        </li>\n    \n                \n        </ul>\n    \n        </li>\n    \n                                        <li    >\n                        <a href=\"/komunikaty\" >Komunikaty</a>\n    \n                            \n        </li>\n    \n                                        <li    >\n                        <a href=\"http://www.opole.pios.gov.pl/\"  target=\"_blank\" >WIOŚ Opole</a>\n    \n                            \n        </li>\n    \n                                        <li     class=\"last\">\n                        <a href=\"/Regulamin_Portalu_Jakosci_Powietrza.pdf\" >Regulamin serwisu</a>\n    \n                            \n        </li>\n    \n                \n        </ul>\n    \n\n        </div>\n    </div>\n</header>\n\n<div class=\"a-big-header a-having-scrollable-background a-having-scroll-shadow \">\n      \n                    <div class=\"narrow-header center-content\">\n    <div class=\"a-logo\"></div>\n    <h1 class=\"title1\">OPOLSKIE</h1>\n    <h1 class=\"title2\">System monitoringu jakości powietrza</h1>\n          </div>\n</div>\n\n                <div id=\"address-bar\">\n                        <nav class=\"breadcrumbs  center-content sidebar-not-included\">\n                <ul>\n                                                                        <li class=\"\">\n                                <a href=\"/\">\n                                                                            <i class=\"icon-home\"></i>\n                                                                        Strona główna\n                                </a>\n                            </li>\n                                                                                                <li class=\"\">\n                                <a href=\"/dane-pomiarowe\">\n                                                                            <i class=\"icon-search\"></i>\n                                                                        Dane pomiarowe\n                                </a>\n                            </li>\n                                                                                                <li class=\"title\">pomiary automatyczne</li>\n                                                            </ul>\n                                            </nav>\n        </div>\n    \n    <div style=\"padding: 15px 0px\"\n         class=\"a-content-container  center-content sidebar-not-included\">\n                    <div class=\"a-content-tile\">\n            <div id=\"a-browse-data-filter-box\" class=\"fluent-menu\" data-role=\"fluentmenu\">\n        <ul class=\"tabs-holder\">\n            <li class=\"active\"><a href=\"#tab_home\">Filtrowanie wyników</a></li>\n                                </ul>\n\n        <div class=\"tabs-content\">\n            <div class=\"tab-panel\" id=\"tab_home\" style=\"display: block;\">\n                <div class=\"full-width\">\n                \n                    <div class=\"tab-panel-group\" style=\"width: 128px\">\n                        <div class=\"tab-group-content\">\n                            <div class=\"tab-content-segment\">\n\n                                <div class=\"a-date-range-chooser\">\n                                    <button class=\"fluent-button dropdown-toggle\">\n                                        <span class=\"icon-pie on-left\"></span>\n                                        <span class=\"button-label\">\n                                                                                      dzienny\n                                                                                  </span>\n                                    </button>\n                                    <ul class=\"dropdown-menu\" data-role=\"dropdown\">\n                                                                              <li><a data-date-range=\"day\" href=\"#\">dzienny</a></li>\n                                                                                                                    <li><a data-date-range=\"month\" href=\"#\">miesięczny</a></li>\n                                                                              <li><a data-date-range=\"year\" href=\"#\">roczny</a></li>\n                                    </ul>\n                                </div>\n                                <div class=\"a-datepicker input-control text\"\n                                                                         >\n                                    <input type=\"text\">\n                                    <button class=\"btn-date\"></button>\n                                </div>\n                            </div>\n                        </div>\n                        <div class=\"tab-group-caption\">Data i typ raportu</div>\n                    </div>\n\n                    <div class=\"tab-panel-group\" style=\"width: 300px\">\n                        <div class=\"tab-group-content\">\n                            <div class=\"tab-content-segment a-view-type-chooser\" style=\"width:62px\">\n                                <button class=\"fluent-big-button dropdown-toggle\">\n                                    <span class=\"icon-home\"></span>\n                                    <span class=\"button-label\">Rodzaj widoku</span>\n                                </button>\n                                <ul class=\"dropdown-menu\" data-role=\"dropdown\">\n                                    <li class=\"checked active\"><a href=\"#\" data-view-type=\"station\">wiele\n                                            parametrów na jednej stacji</a></li>\n                                    <li><a href=\"#\" data-view-type=\"parameter\">jeden parametr na\n                                            wielu stacjach</a></li>\n                                </ul>\n                            </div>\n\n                            <div class=\"tab-content-segment\">\n                                <input class=\"a-s1\" type=\"hidden\" style=\"width:100%\">\n                            </div>\n                        </div>\n                        <div class=\"tab-group-caption\">Sposób przeglądania</div>\n                    </div>\n\n                    <div class=\"tab-panel-group\">\n                        <div class=\"tab-group-content\">\n                            <div class=\"tab-content-segment\">\n                                <input class=\"a-s2\" style=\"width:100%\">\n                                \n                                                                                                                                                                                                                            \n                                                                                                </div>\n                        </div>\n                        <div class=\"tab-group-caption\">Filtr</div>\n                    </div>\n\n                    <div class=\"tab-panel-group a-apply-box\">\n                        <div class=\"tab-group-content\">\n                            <div class=\"tab-content-segment\">\n                                <button class=\"a-apply-filter fluent-big-button\">\n                                    <span class=\"icon-filter\"></span>\n                                    <span class=\"button-label\">Zastosuj</span>\n                                </button>\n                                <div class=\"a-validation-info\" style=\"display:none\">\n                                </div>\n                            </div>\n                        </div>\n                        <div class=\"tab-group-caption\"></div>\n                    </div>\n                </div>\n            </div>\n\n                                                                                                                                                                                                                                                                                                            \n                                                                                                                                                                                                                                                                                                            \n                                                                                                                                                                                            </div>\n    </div>\n\n    <br>\n\n    <div id=\"a-data-browser\">\n        <h2>Użyj powyższego filtru, aby wyświetlić dane</h2>\n\n                  <div class=\"articleContainer\"\n               xmlns:schema=\"http://schema.org/\" typeof=\"schema:WebPageElement\"\n               about=\"/cms/content/pomiary/automatyczne\">\n            <h3 property=\"schema:headline\">UWAGA</h3>\n            <div property=\"schema:text\">Wszystkie wyniki pomiarowe przedstawiane są w czasie CET</div>\n          </div>\n          <br>\n        \n        <div class=\"accordion\" data-role=\"accordion\" data-closeany=\"false\">\n            <div class=\"a-charts accordion-frame\">\n                <a href=\"#\" class=\"heading active\">Wykres</a>\n\n                <div class=\"content\">\n                    <div id=\"chart-container\"></div>\n                </div>\n            </div>\n            <div class=\"a-table accordion-frame\">\n                <a href=\"#\" class=\"heading active\">Tabela</a>\n\n                <div class=\"a-accordion-heading-right\">\n                    eksportuj do:\n                    <a href=\"#\" id=\"table-export-to-calc\">Excel</a>,\n                    <a href=\"#\" download=\"dane_pomiarowe.csv\" id=\"table-export-to-csv\">CSV</a>\n                </div>\n                <div class=\"content\">\n                    <div id=\"table-container\"></div>\n                    <div class=\"a-legend-box\">\n                        <h3>Legenda</h3>\n                        <div class=\"a-legend-item\">\n                          <div class=\"a-item-color a-lv-exceeded\"></div>\n                          <div class=\"a-item-desc\">Przekroczenie poziomu dopuszczalnego.</div>\n                          <div class=\"a-clear\"></div>\n                        </div>\n                        <div class=\"a-legend-item\">\n                          <div class=\"a-item-color a-tv-exceeded\"></div>\n                          <div class=\"a-item-desc\">Przekroczenie poziomu docelowego.</div>\n                          <div class=\"a-clear\"></div>\n                        </div>\n                        <div class=\"a-legend-item\">\n                          <div class=\"a-item-color a-it-exceeded\"></div>\n                          <div class=\"a-item-desc\">Przekroczenie poziomu informowania.</div>\n                          <div class=\"a-clear\"></div>\n                        </div>\n                        <div class=\"a-legend-item\">\n                          <div class=\"a-item-color a-at-exceeded\"></div>\n                          <div class=\"a-item-desc\">Przekroczenie poziomu alarmowego.</div>\n                          <div class=\"a-clear\"></div>\n                        </div>\n\n                        <br>\n                        <div class=\"a-legend-item\">\n                            <div class=\"a-item-color\">1)</div>\n                            <div class=\"a-item-desc\">Brak wymaganego pokrycia danych.</div>\n                            <div class=\"a-clear\"></div>\n                        </div>\n                        <div class=\"a-legend-item\">\n                          <div class=\"a-item-color\">2)</div>\n                          <div class=\"a-item-desc\">Wartość ośmiogodzinnej średniej kroczącej przypisanej do danej godziny stanowi średnią z ośmiu ostatnich ważnych wartości jednogodzinnych (przykładowo: dla godziny 1:00 do obliczeń brane są wartości pomiarów godzinnych z godzin 18:00-1:00, dla godziny 2:00 wartości z godzin 19:00-2:00 itd.).</div>\n                          <div class=\"a-clear\"></div>\n                        </div>\n                        <div class=\"a-legend-item\">\n                          <div class=\"a-item-color\">3)</div>\n                          <div class=\"a-item-desc\">Zgodnie z Wytycznymi Komisji Europejskiej do decyzji 2011/850/UE przekroczenie normy jakości powietrza występuję wtedy, gdy wartość odpowiedniej statystyki (np. średniej rocznej) po zaokrągleniu do ilości miejsc znaczących z jaką podana jest norma przekracza wartość normowaną, np. poziom docelowy dla benzo(a)pirenu wynosi 1&nbsp;ng/m<sup>3</sup>, jeżeli stężenie średnioroczne benzo(a)pirenu na stanowisku pomiarowym wynosi 1,50&nbsp;ng/m<sup>3</sup> to zgodnie z ww. wytycznymi otrzymany wynik zaokrągla się do 2&nbsp;ng/m<sup>3</sup> (co jest przekroczeniem normy), jeżeli stężenie średnioroczne benzo(a)pirenu na stanowisku pomiarowym wynosi 1,48&nbsp;ng/m<sup>3</sup> to otrzymany wynik zaokrągla się do 1&nbsp;ng/m<sup>3</sup> (co nie jest przekroczeniem normy).</div>\n                          <div class=\"a-clear\"></div>\n                        </div>\n                                            </div>\n                </div>\n            </div>\n        </div>\n    </div>\n\n    <div class=\"a-browse-toolbar\">\n      <div class=\"a-toolbar-body\">\n                                                            <div class=\"a-label a-goto-btn\" data-goto=\"#a-data-browser .a-charts\">\n          <i class=\"icon-bars\"></i> wykres\n        </div>\n        <div class=\"a-label a-goto-btn\" data-goto=\"#a-data-browser .a-table\">\n          <i class=\"icon-stats\"></i> tabela\n        </div>\n        <div class=\"a-label a-hide-btn\" data-powertip=\"ukryj\">\n          <i class=\"icon-arrow-up-2\"></i>\n        </div>\n      </div>\n    </div>\n    <div class=\"a-browse-toolbar2\">\n      <div class=\"a-toolbar-body\">\n        <div class=\"a-label a-show-btn\" data-powertip=\"pokaż pasek narzędzi\">\n          <i class=\"icon-arrow-down-2\"></i>\n        </div>\n      </div>\n    </div>\n\n    <div id=\"a-export2xls-help\">\n      <p>Do eksportu danych do arkusza kalkulacyjnego można wykorzystać schowek, w tym celu:</p>\n      <ol>\n        <li>Naciśnij kombinację klawiszy <kbd>CTRL+C</kbd>.</li>\n        <li>W arkuszu kalkulacyjnym użyj opcji <i>Wklej</i> lub naciśnij kombinację klawiszy <kbd>CTRL+V</kbd>.</li>\n      </ol>\n    </div>\n\n    <script type=\"application/javascript\">\n        var date = 1486425600000;\n        var app = app || {};\n        app.config = app.config || {};\n        app.config.DataBrowser = {\n            dataUrl: '/dane-pomiarowe/pobierz',\n            stationState: 'active',\n                      configUrl: '/dane-pomiarowe/wczytaj-konfiguracje',\n                      useHistoryAPI: !!(window.history && history.pushState),\n            measType: 'auto',\n            data: { // null, jeśli selektor ma być domyślnie niewypełniony\n                viewType: 'station',\n                viewTypeEntityId: '118',\n                dateRange: 'day',\n                date: date + 3600000, // CET offset\n                channels: [461]\n            }\n        };\n    </script>\n\n    </div>\n        \n\n    </div>\n\n    <div class=\"a-footer\">\n        W serwisie wykorzystywane są pliki cookies w celu zapamiętania stanu elementów interfejsu.\n        <a id=\"acceptCookiesButton\" class=\"button small\" onclick=\"acceptCookies()\">Akceptuję</a>\n    </div>\n    <script type=\"text/javascript\">\n        function acceptCookies() {\n            Cookies.set('cookiesAccepted', 'yes');\n            $('.a-footer').slideUp();\n        }\n    </script>\n\n            <script type=\"text/javascript\" src=\"/static/core.js?v3\"></script>\n        \n    \n    <script type=\"text/javascript\" src=\"/static/browse.js?v3\"></script>\n    \n    <script src=\"/js/routing?callback=fos.Router.setData\"></script>\n    <script type=\"application/javascript\">\n        $(function () {\n            // separator w zależności od locale (jeśli występuje pl to użyj `;`)\n            var i18n = navigator.languages || (navigator.userLanguage && [navigator.userLanguage]) || (navigator.language && [navigator.language]) || [],\n                separator = (i18n.indexOf('pl') !== -1 ? ';' : ',');\n\n            //\n            /**\n             * Pozbywa się wrapperów wartości `\"` jeżeli występują.\n             * @param {string} csvValue\n             * @returns {string}\n             */\n            var trim = function(csvValue) {\n                return csvValue.replace(/^\"(.*)\"$/, '$1');\n            };\n            //\n            var csvBtn = $('#table-export-to-csv');\n            csvBtn.on('click', function (e) {\n                var data = $('#table-container > table').table2CSV({\n                    delivery: 'value',\n                    separator: separator,\n                });\n                var lines = data.split('\\n');\n\n                //begin: dostosowanie nagłówka\n                var headerLine = lines[0],\n                    headers = headerLine.split(separator),\n                    newHeaderLine = [headers[0]];\n\n                var len = (headers.length - 1) / 2;\n                for (var i = 1; i <= len; ++i) {\n                    var j = i + len;\n                    newHeaderLine.push('\"' + trim(headers[i]) + ' ' + trim(headers[j]) + '\"');\n                }\n                newHeaderLine = newHeaderLine.join(separator);\n                // usunięcie przypisów\n                newHeaderLine = newHeaderLine.replace(/\\d\\)/g, '');\n                lines.splice(0, 1, newHeaderLine);\n                //end: dostosowanie nagłówka\n\n                data = lines.join('\\n');\n\n                // usunięcie &nbsp;\n                data = data.replace(/&nbsp;/g, ' ');\n\n                var link = this,\n                  d = new Date(),\n                  now = d.format('yyyy-mm-dd_HH-MM-ss'),\n                  filename = 'dane-pomiarowe_' + now + '.csv';\n                FileSaver.saveAs(data, \"text/csv\", \"UTF-8\", filename, link);\n            });\n\n            var calcBtn = $('#table-export-to-calc');\n            var help = $('#a-export2xls-help');\n            calcBtn.on('click', function (e) {\n              e.preventDefault();\n              var table = $('#table-container > table');\n\n              $.Dialog({\n                overlay: true,\n                flat: true,\n                icon: '<i class=\"icon-file-excel\"></i>',\n                title: 'Eksportowanie danych do arkusza kalkulacyjnego',\n                content: help.html(),\n                padding: 10,\n                // dimm are set in css\n                onShow: function(_dialog){\n                  app.utils.selectContent(table.get(0));\n                },\n                onClose: function () {\n                  console.log('# A #');\n                }\n              });\n              // there is no close event in Dialog so one can bind to the close btn\n              $('.window.flat').find('button.btn-close').one('click', function() {\n                app.utils.clearSelection();\n              });\n\n            });\n\n            //\n            // toolbar\n            //\n            var isTransitionSupported = app.utils.supportCssProperty('transition');\n\n            var toolbar = $('.a-browse-toolbar');\n            var toolbar2 = $('.a-browse-toolbar2'); // przycisk \"pokaż\"\n\n            toolbar.find('.a-goto-btn').on('click', function(e) {\n              var selector = $(this).attr('data-goto');\n              app.scrollToEl(selector);\n            });\n\n            toolbar.find('.a-hide-btn').on('click', function(e) {\n              if (!toolbar.hasClass('a-hidden')) {\n                app.utils.cssTransition(toolbar, 'a-hidden', function() {\n                  toolbar2.fadeIn();\n                });\n                if (!isTransitionSupported) {\n                  toolbar2.fadeIn();\n                }\n              }\n            });\n            toolbar2.find('.a-show-btn').on('click', function(e) {\n              if (toolbar.hasClass('a-hidden')) {\n//                app.utils.cssTransition(toolbar, 'a-hidden', function() {\n//                  toolbar2.fadeOut();\n//                });\n                toolbar.toggleClass('a-hidden');\n                toolbar2.fadeOut(600);\n              }\n            });\n\n            toolbar.find('.a-shrink-table-btn').on('click', function(e) {\n              var cntr = $('#table-container');\n              cntr.children('table').addClass('a-shrinked-table');\n              cntr.doubleScroll('refresh');\n\n              $(this).hide();\n              toolbar.find('.a-expand-table-btn').show();\n            });\n            toolbar.find('.a-expand-table-btn').on('click', function(e) {\n              var cntr = $('#table-container');\n              cntr.children('table').removeClass('a-shrinked-table');\n              cntr.doubleScroll('refresh');\n\n              $(this).hide();\n              toolbar.find('.a-shrink-table-btn').show();\n            });\n        });\n    </script>\n</body>\n</html>"

我无法找到我想要的东西。

1 个答案:

答案 0 :(得分:-1)

我相信该表的数据实际上来自JSON服务。

const {nodeInterface, nodeField} = nodeDefinitions(
    (globalId, context) => {
        const {type, id} = fromGlobalId(globalId);
        if (type === 'bar') {
            // get Bar with id==id if context.user has access
            return getBar(context.user, id);
        } else {
            return null;
        }
    },
    (obj) => {
        // return the object type
    }
);

如果您解码POST http://www.opole.pios.gov.pl:81/dane-pomiarowe/pobierz HTTP/1.1 Host: www.opole.pios.gov.pl:81 Connection: keep-alive Content-Length: 200 Accept: application/json, text/javascript, */*; q=0.01 Origin: http://www.opole.pios.gov.pl:81 X-Requested-With: XMLHttpRequest /User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Content-Type: application/x-www-form-urlencoded; charset=UTF-8 DNT: 1 Referer: http://www.opole.pios.gov.pl:81/dane-pomiarowe/automatyczne/stacja/118/parametry/461/dzienny/07.02.2017 Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8,de;q=0.6 Cookie: _gat=1; _ga=GA1.3.1335419632.1486488241 query=%7B%22measType%22%3A%22Auto%22%2C%22viewType%22%3A%22Station%22%2C%22dateRange%22%3A%22Day%22%2C%22date%22%3A%2207.02.2017%22%2C%22viewTypeEntityId%22%3A%22118%22%2C%22channels%22%3A%5B461%5D%7D HTTP/1.1 200 OK Server: nginx/1.6.2 Content-Type: application/json Connection: keep-alive X-Powered-By: PHP/5.4.16 Cache-Control: no-cache Date: Tue, 07 Feb 2017 17:25:49 GMT Content-Length: 1470 {"success":true,"data":{"charts":[],"title":"Dane pomiarowe dla stacji Opole, ul. Koszyka w dniu 07.02.2017 r.","unitLabel":"&micro;g\/m<sup>3<\/sup>","series":[{"label":"Py\u0142 zawieszony PM10","measType":"auto","paramLabel":"Py\u0142 zawieszony PM10","paramId":"pm10","paramCode":"PM10","paramPostfix":"","aggType":"A1h","ord":7,"interval":3600,"count":24,"retroCount":2,"startTime":1486425600,"extStartTime":1486418400,"coverageRate":0.75,"isAvgValid":true,"thresholds":{"at":null,"it":null,"tv":null,"lv":null,"atDecimals":0,"itDecimals":0,"tvDecimals":0,"lvDecimals":0},"data":[["1486418400","57.3032"],["1486422000","55.3116"],["1486425600","59.175"],["1486429200","56.1021"],["1486432800","62.4833"],["1486436400","67.5783"],["1486440000","66.4557"],["1486443600","68.622"],["1486447200","64.8019"],["1486450800","65.7004"],["1486454400","61.8585"],["1486458000","67.2359"],["1486461600","57.9348"],["1486465200","48.9005"],["1486468800","51.9315"],["1486472400","54.7842"],["1486476000","52.2321"],["1486479600","53.8026"],["1486483200","47.3977"],["1486486800","46.0068"]],"avg":{"avg":false,"min":"46.0068","max":"68.622"},"thresholdsForAvg":{"avg":{"at":300,"it":200,"tv":null,"lv":50,"atDecimals":0,"itDecimals":0,"tvDecimals":0,"lvDecimals":0},"min":null,"max":null},"decimals":0,"unit":"ug\/m3","unitLabel":"&micro;g\/m<sup>3<\/sup>","scaleMin":null,"scaleMax":null,"chartTooltipContent":"%y.# %ly o godz. %x"}],"dateFormat":"H:00","viewType":"station"}} 参数,它实际上也是JSON:

query

因此,在较高级别,您可以为此JSON创建{"measType":"Auto","viewType":"Station","dateRange":"Day","date":"07.02.2017","viewTypeEntityId":"118","channels":[461]} 并解析结果。上传数据的好方法是使用WebClient.UploadString

使用JSON.Net以JToken.Parse为例解析结果,您可以访问要查找的元素。

POST

结果如下:

string url = "http://www.opole.pios.gov.pl:81/dane-pomiarowe/pobierz";
string data = "query=" + HttpUtility.UrlEncode("{\"measType\":\"Auto\",\"viewType\":\"Station\",\"dateRange\":\"Day\",\"date\":\"07.02.2017\",\"viewTypeEntityId\":\"118\",\"channels\":[461]}");

System.Net.WebClient wc = new System.Net.WebClient();
wc.Headers[System.Net.HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded; charset=UTF-8";
string response = wc.UploadString(url, data);

Newtonsoft.Json.Linq.JToken jsonResponse = Newtonsoft.Json.Linq.JToken.Parse(response);

DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
foreach (var entry in jsonResponse["data"]["series"][0]["data"])
{
    Response.Write("UTC Time: " + epoch.AddSeconds((int)entry[0]) + ", Value: " + entry[1] + "<br>");
}