Parsing a web page
This example permits to parse all the elements inside a specific web page. These will be written in a data set (named Results).
The selection of the web page and, eventually, the filter to apply on the elements are specified in a dialog window that will be opened when the script is started.
This example permits to parse all the elements inside a specific web page. These will be written in a data set (named Results).
The selection of the web page and, eventually, the filter to apply on the elements are specified in a dialog window that will be opened when the script is started.
macrostep parsewfilter; dataset out=temp; newvar url_page filter=text; url_page="&url_page"; filter="&filter"; output; run; PROC MULTIWEBPARSER DICT=temp OUT=results; VARMAINPAGE url_page; varselect filter; RUN; mend; macrostep parsenofilter; dataset out=temp; newvar url_page filter=text; url_page="&url_page"; output; run; PROC MULTIWEBPARSER DICT=temp OUT=results; VARMAINPAGE url_page; RUN; mend; scl; JTextField url_page = new JTextField(); JTextField filter = new JTextField(); Object[] message = { "URL of the web page:", url_page, "Filter:", filter}; int option = JOptionPane.showConfirmDialog(MainGUI.desktop, message, "Specify the parameters", JOptionPane.OK_CANCEL_OPTION); if (option == JOptionPane.OK_OPTION){ String text_url_page=url_page.getText(); String text_filter=filter.getText(); if (!text_url_page.equals("")) { ADDDEFINE("url_page",text_url_page); if (!text_filter.equals("")) { ADDDEFINE("filter",text_filter); EXECUTEMACROSTEP("parsewfilter"); } else EXECUTEMACROSTEP("parsenofilter"); } }; run; |