• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Get CSS Attributes using Java

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to access a website using Java and get from it the CSS properties of say a specific div for example. So, I need to know that that div has a width of 500px, background-color red etc etc. It may be because that div has a class, an ID or simply because it is a div. The most important thing is that because of CSS inheritance, I need to know exactly what that div's properties are. To make it clear, I need the final values in a similar way as the attribute properties that appear to the right hand part of Firebug when you do an inspect element of a particular HTML tag. All I need are the final values and properties (not what has been overridden). I first tried to research if there is something that makes Firebug save on a text file and then I analyze it using Java but I think it will get too dependent on what Firebug's features will be in the future so it may be risky. Another idea was to build a tree in Java and put in it CSS of each HTML tag so the lowest node is the final property. Is there any inbuilt function in Java that can get you the actual CSS properties of specific HTML tag ? This would avoid me having to rewrite the wheel Thanks a lot for your kind help!
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have a look at WATIJ. I think this will solve your problem.
 
Justin Mifsud
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Siddhesh,

Many thanks for your reply. I took a look at Watij and it seems to have a good HTML parser feature. However, I cannot locate any info about CSS on it. As I said, I need to be able to specify a particular HTML tag and I get back its CSS properties and their values. Does Watij have this feature please ?

Thanks once again,

Justin
 
Siddhesh Deodhar
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its not only a parser but it is a web automation tool. I had used it long time back to automate user workflows. By now it should have been advanced enough to support your requirement. It had/has vast documentation !
 
Marshal
Posts: 79931
396
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Maybe it's a bit late, but welcome to JavaRanch Justin Mifsud
 
Justin Mifsud
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ritchie.
 
The moth suit and wings road is much more exciting than taxes. Or this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic