Search code examples
htmlconvertersicalendarrfc5545

How can convert html file to ics (iCal) file


Hello I would like to convert a html file ( web site ) to ics (iCal) file. Is it possible? If yes how can I do that? Knows anyone?

Thank you


Solution

  • Assuming that you mean a HTML file that contains data about a certain event, such as a meeting or a convention, what you can do is parse the HTML for the relevant data and create a new iCal file from that.

    Study the HTML, find out how to use regular expressions to find the data that you need, then create a new iCal file and write the parsed data to it. You'll need the following steps:

    1) GET the HTML to a local file

    2) Parse it, producing an in-memory object with the parsed values

    3) Validate that in-memory object against a number of rules (any rules that you can think of that apply in your case, such as making sure that the date and time are in a correct format and that the date is in the future, etc.)

    4) Write the data to a file in iCal (RFC 2445) format.

    The format definition of iCal can be found at http://www.ietf.org/rfc/rfc2445.txt but you'll find this page easier to understand: http://reefknot.sourceforge.net/bootstrap-guide/indexs05.html

    Good luck!