473,387 Members | 1,572 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Extracting a javascript var from an html page?

1
Hey,

I need to parse some information from a page, very unfortunately it's contained in a javascript format variable which is then used by a function to generate some sort of gui.

Anyway, here is the piece of script extracted from the page :
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript"><!--
  2.     var myMenu =
  3.     [
  4.         ['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + ctThemeXPBase + 'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="' + ctThemeXPBase + 'folderopen1.gif" /></i></span>', '/', '#', '', '', 
  5.         ['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + ctThemeXPBase + 'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="' + ctThemeXPBase + 'folderopen1.gif"></i></span>', 'Cat1', '#', '', '',
  6.         ['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + ctThemeXPBase + 'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="' + ctThemeXPBase + 'folderopen1.gif"></i></span>', 'Cat1.1', '#', '', '',,['','TitleDoc1.1 (Doc1.1.txt)','https://***/docman/view.php/22/9/Doc1.1.txt','','DescDoc1.1 10Char' ],
  7.         ],
  8.         ['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + ctThemeXPBase + 'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="' + ctThemeXPBase + 'folderopen1.gif"></i></span>', 'Cat1.2', '#', '', '',,
  9.         ],,['','Agenda1 (Dummy.txt)','https://***/docman/view.php/22/14/Dummy.txt','','DescriptionAgenda1' ],['','TitleDoc1 (Doc1.txt)','https://***/docman/view.php/22/8/Doc1.txt','','DescDoc1 10 char' ],
  10.         ],
  11.         ['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + ctThemeXPBase + 'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="' + ctThemeXPBase + 'folderopen1.gif"></i></span>', 'Cat2', '#', '', '',,['','TitleDoc2 (Doc2.txt)','https://***/docman/view.php/22/10/Doc2.txt','','DescriptionDoc2' ],['','TitleDoc2.1 (Doc2.1.txt)','https://***/docman/view.php/22/12/Doc2.1.txt','','DescriptionDoc2.1' ],['','TitleDoc2.2 (Doc2.2.txt)','https://***/docman/view.php/22/11/Doc2.2.txt','','DescriptionDoc2.2' ],
  12.         ],
  13.         ['<span class="JSCookTreeFolderClosed"><i><img alt="" src="' + ctThemeXPBase + 'folder1.gif" /></i></span><span class="JSCookTreeFolderOpen"><i><img alt="" src="' + ctThemeXPBase + 'folderopen1.gif"></i></span>', 'Uncategorized Submissions', '#', '', '',,['','uncategDocument (DocPasCateg.txt)','https://***/docman/view.php/22/13/DocPasCateg.txt','','DescriptionUncatDoc' ],
  14.         ],        ]
  15.     ];
  16.     ctDraw ('myMenuID', myMenu, ctThemeXP1, 'ThemeXP', 0, 1);
  17.     --></script>
  18.  
It's confusing, sorry :/
I need to extract some informations from here, like categories names (Cat1, Cat1.1, Cat2...) and documents inside these categories (
Any way to retrieve this var from Python without writing many complex regexp? I'd like to navigate it as some sort of list which would make things much easier to parse imo.

Thanks :)
May 3 '10 #1
1 1782
Glenton
391 Expert 256MB
I think regular expressions were more or less designed for this kind of thing. Embrace them! They will (slowly) become your friends...
May 4 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Jon Haakon | last post by:
Hi, I'm developing a websolution using ASP and DHTML technology that's running on a MS IIS webserver. My solution is frame based with a toolbar on top, a hidden frame for scripts in the...
4
by: Caroline | last post by:
Rather than opening a new window, how can I add a text (or HTML code) in the same HTML page, in a specific location? The code I tried is the following: <head> <script language="JavaScript">...
13
by: gsb | last post by:
Object tag to write HTML page to via JavaScript? I've used iFrames and Objects to load web pages into another page. I want to do similar but not load a uri, rather write the page, <HTML>...
13
by: nobody | last post by:
Hello all, I've searched just about everything and although I can see that other people are having problems, but theirs don't seem to relate, so in a last ditch attempt, my posting! Script...
5
by: acord | last post by:
Hi, I m getting annoying display problem when placing javascript tags in a html page. Should the javasscript tags placed at the beginning of a html page before anything start? or placed between...
17
by: =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= | last post by:
Hello, I have build a website with approximately 30 html-pages. When I search this website in Google, I see the index.html or home.html on this website, but also other html-pages on this...
4
by: davidiwharper | last post by:
Hi everyone, I am rewriting a basic "email data to administrator" script to include an error check, which will ensure that all fields are filled with at least some data. However, there is a...
10
by: paulie | last post by:
Hi, I have been experiencing an issue when trying to use AJAX to reload a DIV area using a timer of 2000ms, which contains a html page with another DIV and javascript. Scenario -------------...
4
by: djlender | last post by:
Hi All! I'm hoping someone can help me with this situation. I am a developer working on a project that has a video voting page. The situation is this: The parent page has an iFrame ( named...
17
by: happyse27 | last post by:
Hi All, The html page(see item a below) is calling javascript(item b below), but cant work as the page show blank. Not sure if the method of calling is wrong(in terms of default directory) or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.