Facing new challenges everyday

Using regular expressions in Groovy script to retrieve data from html pages

March 31st, 2008

I have been working with regular expressions in Java, regular expressions are very useful to retrieve some data based on document structure. In my example I’m extracting cellular model and brand based on particular html document structure, take a look on html code below:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<html>
  <head>
     <title>Regular expressions sample data
  </title></head>
  <body>
      <font style="font-size: 8pt;" face="Verdana"><br />
      </font><font face="Verdana" size="1"><b>Audiovox:<br />
      </b></font>
      <a href="http://cellular.com/audiovox9500.shtml">
      <font size="1">CDM 9500</font></a><font size="1">
      |
      </font>
      <a href="http://cellular.com/thera.shtml">
      <font size="1">PDA - (Thera)</font></a><font size="1">
      |
      <a href="http://cellular.com/audiovoxppc6600.shtml">
      PDA - PPC6600 (Harrier)</a>.<br />
      <br />
      </font>
      <font style="font-weight: 700;"
         face="Verdana" size="1">Cyberbank:<br />
      </font>
      <a href="http://cellular.com/cyberbankpoz.shtml">
      <font size="1">CB 0870 BR (PoZ)</font></a><font size="1">
      |
      </font>
      <a href="http://cellular.com/cyberbank_cb880.shtml">
      <font size="1">CB 0880 BR (Triton)</font></a><font size="1">
      |
      <a href="http://cellular.com/cyberbank_x315.shtml">
      CP X315 BR (PoZ EVDO)</a>.<br />
      <br />
      </font><b><font face="Verdana" size="1">Compaq:<br />
      </font></b><font size="1">
      <a href="http://cellular.com/compaq_ipac3700.shtml">
      IPAC-3700</a>.<br />
      <br />
  </font></body>
</html>

(more…)

Post to Twitter

My first Apple machine

March 21st, 2008

I finally have my own Apple machine, now I can develop iPhone applications too. :)

Mac MiniMac MiniMac Mini

Post to Twitter

Playing with Android SDK

March 20th, 2008

Yesterday I wrote a small app using Android SDK, this app is called on every incoming call showing a image downloaded from internet, the first challenge was discover how can I catch a system event like a phone call, I could find the answer in this post, all the other questions could be answered by searching on Andoid Developers Google Groups.
(more…)

Post to Twitter

Creating JSF applications with JRuby and ActiveRecord-JDBC (Part 2)

March 16th, 2008

My last article about this topic showed how can we start the development of an JSF webapp with JRuby and ActiveRecord-JDBC, we will discuss on this article how can we create the dao, domain class and the view used to show costumer data.

In this example, CostumerDao illustrate how can we perform some data persistence/retrieval using ActiveRecord domain classes, we defined MyCostumer JRuby class to act as a proxy of our domain class:
(more…)

Post to Twitter

Creating JSF applications with JRuby and ActiveRecord-JDBC (Part 1)

March 16th, 2008

Is there any way to create JSF applications using scripting languages and its own persistence engines? The answer is: Yes! After some hours trying to integrate JSF + JRuby + ActiveRecord I finally could get a very simple application working, this application contains only one page where the user can add some costumer data, we have jsp as view, spring as IoC container and integration point with JRuby, ActiveRecord-JDBC as ORM.

The page has a managedbean defined as Ruby class, each Ruby bean must implement a Java interface to allow integration with Java/Spring, when the bean is requested by Spring a Java proxy class is instantiated based on its Java interface and then all Ruby code can be consumed properly.

If you wanna try by yourself you must create a webapplication and add the jars described on my previous post (except groovy-1.5.4.jar) plus these jars below on WEB/lib folder:
(more…)

Post to Twitter

Next Page »

Visitors Around the World

Polls

How Is My Site?

View Results

Loading ... Loading ...

Categories

Meta

Links

hosted by easy2use.net