Sunday, January 25, 2015

Coding again...

Coding again...  It's just over a year since the last time I wrote any Java code.  Today I wrote a short little program, doing a little web scraping – and it works.  I've forgotten tons of details, but I know the concepts very well (I should, after 15 years of Java experience!), so I'm picking those details up very quickly.  Before I could start writing code, I had to renew my subscription for my IDE (JetBrains' IntelliJ IDEA – I love the darned thing).  Then I discovered that IDEA doesn't like the default OS X 10.10 Java version – it wants a down-rev (Java 6) because of problems in the later JRE libraries.  So off I went to downgrade my Java.  That made all sorts of other things complain, and my log was growing at a prodigious rate – had to track down three hateful apps and figure out how to make them shut up.  Finally I could try writing some code!

My dumb little program reads a URL to get the HTML content, then parses it with a regular expression to get the three particular parts that I wanted.  It took a while, but I got it all working.  One of these fine days it will be part of something I want on my new blog: the ability to present third-party content that lives at a URL that varies (typically daily or more often).  JavaScript running in the browser is not permitted to look at the HTML of any site other than the one being browsed, so it can't do things like this.  My plan is to have a program that runs a few times a day on a server, finds all these content pointers, and then updates an assets file on the blog's server so that information is available to the code running on the reader's browser...

No comments:

Post a Comment