I’m working on a small project, it is a web harvester created in python, but my problem revolves around constructing a javascript user interface for selecting DOM nodes a finding their Xpath’s.
So i solved the technical part but my problem is how to create a interface for the script.
I was planning to construct a html form in a iframe which will a user fill with selected nodes.
The template of xpath’s is passed to the python script and then the information is processed.
So the plan is a user clicks on the “execute button“, the higlighting starts, it highlights on mouseover event and on onclick event the xpath is calculated and added to appropriate field.
Momentarily my idea is to insert a iframe into the selected page, execute the script and collect the information in the manner described above.
So i was interested if you have a better idea, or some suggestion how to make the interface because i don’t want to use a complicated approach if there is an easier one.
Regards FJ
My first guess is that you want to build a generic webpage scraper where user can specify certain DOM nodes in the current active page. I would suggest using a bookmarklet based solution. You give the user a bookmarklet and he drag it over to his bookmarks toolbar. Whenever he need to scrape a page he simply clicks the bookmark and you start injecting your javascript code in that page (ie, in <script> tags)
Once your scripts load you should mimick the same behavior that you were talking about. Highlight DOM element on mouse over and select on click. Check the firebug DOM Explorer as to how it should work and look. On submission you can send the data to your server via JSONP or an iframe call and switch off your scripts