Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7802399
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:15:11+00:00 2026-06-02T01:15:11+00:00

This is the question I asked yesterday. I was able to get the required

  • 0

This is the question I asked yesterday. I was able to get the required data. The final data is like this. Please follow this link.

I tried with the following code to get all the infobox data

                                content = content.split("}}\n");
                                for(k in content)
                                {
                                    if(content[k].search("Infobox")==2)
                                    {
                                        var infobox  = content[k];
                                        alert(infobox); 
                                        infobox = infobox.replace("{{","");
                                        alert(infobox);
                                        infobox = infobox.split("\n|");
                                        //alert(infobox[0]);
                                        var infohtml="";
                                        for(l in infobox)
                                        {
                                            if(infobox[l].search("=")>0)
                                            {
                                                var line = infobox[l].split("=");

                                                infohtml = infohtml+"<tr><td>"+line[0]+"</td><td>"+line[1]+"</td></tr>";

                                            }
                                        }
                                        infohtml="<table>"+infohtml+"</table>";
                                        $('#con').html(infohtml);
                                        break;
                                    }
                                }

I initially thought each element is enclosed in {{ }}. So I wrote this code. But what I see is, I was not able to get the entire infobox data with this. There is this element

{{Sfn|National Informatics Centre|2005}}

occuring which ends my infobox data.

It seems to be far simpler without using json. Please help me

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:15:12+00:00Added an answer on June 2, 2026 at 1:15 am

    Have you tried DBpedia? Afaik they provide template usage information. There is also a toolserver tool named Templatetiger, which does template extraction from the static dumps (not live).

    However, I once wrote a tiny snippet to extract templates from wikitext in javascript:

    var title; // of the template
    var wikitext; // of the page
    var templateRegexp = new RegExp("{{\\s*"+(title.indexOf(":")>-1?"(?:Vorlage:|Template:)?"+title:title)+"([^[\\]{}]*(?:{{[^{}]*}}|\\[?\\[[^[\\]]*\\]?\\])?[^[\\]{}]*)+}}", "g");
    var paramRegexp = /\s*\|[^{}|]*?((?:{{[^{}]*}}|\[?\[[^[\]]*\]?\])?[^[\]{}|]*)*/g;
    wikitext.replace(templateRegexp, function(template){
        // logabout(template, "input ");
        var parameters = template.match(paramRegexp);
        if (!parameters) {
            console.log(page.title + " ohne Parameter:\n" + template);
            parameters  = [];
            }
        var unnamed = 1;
        var p = parameters.reduce(function(map, line) {
            line = line.replace(/^\s*\|/,"");
            var i = line.indexOf("=");
            map[line.substr(0,i).trim() || unnamed++] = line.substr(i+1).trim();
            return map;
        }, {});
        // you have an object "p" in here containing the template parameters
    });
    

    It features one-level nested templates, but still is very error-prone. Parsing wikitext with regexp is as evil as trying to do it on html 🙂

    It may be easier to query the parse-tree from the api: api.php?action=query&prop=revisions&rvprop=content&rvgeneratexml=1&titles=….
    From that parsetree you will be able to extract the templates easily.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I asked a similar question like this yesterday but after waiting for ever I
I asked this question yesterday about storing a plot within an object. I tried
This is a follow-up to a question I asked yesterday. What I want to
this is actually a follow up to a question I asked yesterday about problems
Yesterday i asked this question: Get current time and set a value in a
Following on from this question I asked yesterday: Can I shorten this regular expression?
As a follow up question to this one I asked yesterday , are there
I asked this question yesterday, and at the time it was just what I
i asked this question yesterday but it doesnt seem to have asked properly so
This is linked to a question I asked yesterday. Briefly, the problem I'm having

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.