如何使用python使用xmlhttp请求抓取网页

时间:2020-04-07 06:38:44

标签: python xmlhttprequest

我正在尝试抓取具有以下javascript的网页(http://www.licpensionfund.in/index.php?option=com_content&view=article&id=47):

function onChange(Exchng) {
    //alert(Exchng);            
    var Exchng = btoa(Exchng);
    document.getElementById("commoditySymbol").innerHTML = "<table cellpadding='0' cellspacing='0' width='100%' ><tr><td align='center' valign='center'><img src='images/stories/generator1.gif'></td></tr></table>";
    var url = "Navnew.php?Exchg=" + Exchng;
    include(url, 'commoditySymbol');
}

function include(xUrl, xId) {
    flag = false;
    var xmlhttp = false;
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
        try {
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
            xmlhttp = false;
        }
    }
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
        xmlhttp = new XMLHttpRequest();
    }
    if (xmlhttp == null)
        document.location = "http://download.microsoft.com/download/8/8/8/888f34b7-4f54-4f06-8dac-fa29b19f33dd/msxml3.msi"
    xmlhttp.open("GET", xUrl, true);
    xmlhttp.onreadystatechange = function() {
        if (xmlhttp.readyState == 4) {
            document.getElementById(xId).innerHTML = xmlhttp.responseText;
        }
    }
    flag = true;
    xmlhttp.send(null);
}

... 输入id =“ submit” value =“ Go” type =“ button” onclick =“ javascript:onChange(document.getElementById('scheme')。value)”

我需要提取单击上面的“开始”按钮时收到的xml数据。怎么办呢?搜索了很多,但找不到任何解决方案。任何指针都会有所帮助。

0 个答案:

没有答案
相关问题