Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to add a cookie to answer the initial course offerings question: </p> <blockquote> <p><strong>class search course catalog</strong><br> Indicate which course offerings you wish to see<br> * ASU Campus<br> * ASU Online</p> </blockquote> <p>You do this by simply adding </p> <pre><code>conn.setRequestProperty("Cookie", "onlineCampusSelection=C"); </code></pre> <p>to the <code>HttpURLConnection</code>. </p> <p>I found the cookie by using Google Chrome's Developer Tools (Ctrl-Shift-I) and looked at <code>Resources</code> tab then expanded <code>Cookies</code> to see the <code>webapp4.asu.edu</code> cookies.</p> <p>The following code (mostly yours) gets the HTML of the page you are looking for:</p> <pre><code>public static void main(String[] args) { System.out.println(download("https://webapp4.asu.edu/catalog/classlist?c=TEMPE&amp;s=CSE&amp;n=100&amp;t=2141&amp;e=open&amp;hon=F")); } static String download(String urlToRead) { java.net.CookieManager cm = new java.net.CookieManager(); java.net.CookieHandler.setDefault(cm); String result = ""; try { URL url = new URL(urlToRead); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestMethod("GET"); conn.setRequestProperty("Cookie", "onlineCampusSelection=C"); BufferedReader rd = new BufferedReader(new InputStreamReader( conn.getInputStream())); String line; while ((line = rd.readLine()) != null) { result += line + "\n"; } rd.close(); } catch (Exception e) { e.printStackTrace(); } return result; } </code></pre> <p>Although, I'd use a real parser like <a href="http://jsoup.org/" rel="nofollow">jsoup</a> or <a href="http://htmlparser.sourceforge.net/" rel="nofollow">HTML Parser</a> to do the actual parsing job.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload