Reading page metadata using jSoup in ColdFusion
The ability to query a web page for metadata is one of the main features I use for creating content here. ColdFusion (and the jSoup ColdBox module) makes the task trivial.
I am using the jSoup connect() method to read the document although it is also possible to pull in the HTML using cfhttp. The code will follow redirects and overrides the user agent to avoid potential filters. I have noticed some web application firewalls will reject the request, I assume that could be because they block spider requests from my VPS provider (Digital Ocean). The same request works fine when run locally.
The next step is iterating through the meta properties to pull out the opengraph and twitter metadata which is then returned to the caller so that data may be acted upon.
Although this example is specific to ColdBox, it should be easily portable to a non-ColdBox app.
The Value Class java.time.LocalDateTime Cannot Be Converted To A Date In ColdFusion
I ran in to an annoying “feature” in ColdFusion when using MySQL connector jars version 8.0.23+ when trying to retrieve a timestamp from the database. When trying to date format the value I received the error “ java.time.LocalDateTime Cannot Be Converted To A Date”.
One solution would be rolling back the MySQL driver version to 8.0.22 which was the last version that worked correctly with ColdFusion as per Ben's post on the issue.
I did find another solution at Adobe's issue tracker site here: https://tracker.adobe.com/#/view/CF-4211276 . Using the MySQL CAST() feature to cast the column to char in the SELECT, i.e. CAST(column as char) AS column, will resolve the issue, as noted by Anthony K.