tags:

views:

133

answers:

2

I want to read the content from an external page, convert that into a predefined format, and then enter it into a database.

This is just for fun--it's taking an event list and copying the events to my own site.

Take this page, and manipulate it to fit a different format...

Is it possible to do this with jquery?

A: 

Yes, up to reading, and convert to another format, but of course not into a database.

Although the html formatting on the page you given is not too good (like the use of strong within the div, instead of giving meaningful name/class/id to the item), as long as all events are in same format, it is not difficult to use JQ to convert into, whatever format you want.

xandy
Yea, their markup is pretty crummy... :)
Kevin Brown
Is it possible to save it as a csv file? I need some way to get it into my database...Maybe I could just format the output as a csv file--and then copy/paste...
Kevin Brown
As long as you know which container contains what information, any format would be possible.
xandy
+1  A: 

It's possible but only to a degree. You're going to need some server-side code to help you out. Without seeing your predefined format, it's tough to make any suggestions.

At an abstract level, I'm assuming that an event will be composed of a time, a date, and a location. From here, it would seem as if you'd need to break down the process into the following:

Client-side

  • Find each time, date, and location.
  • For each of these, you're going to want to format them into your pre-defined representation.
  • Submit this data to the server.

Server-side

  • Perform any necessary validation or processing
  • Insert it into the database
Tom
Absolutely right. I have no idea how to do that.
Kevin Brown
It'd be easiest if you have contorl of the markup. You could create a container (like a div), assign it classname (like "event"), and then leverage jQuery's selector power to iterate through the events (think of something like $('div.event').each(function() { // grab the title, date, location, and build up a string here });
Tom
Perhaps I should start a new question that is more specific..?
Kevin Brown
I was thinking along those lines, Tom! :)Unfortunately, I don't have control over their markup...
Kevin Brown