如何编写 Greasemonkey 脚本来处理 __doPostBack()

发布于 2024-09-30 03:42:24 字数 1046 浏览 3 评论 0原文

我有科学计算背景,并且确实有一些流行和不流行(临时)编程语言的历史,但我对客户端编程和 JavaScript 完全陌生。

我之前为 Greasemonkey 设置编写过一些简单的 JavaScript,但仅此而已。

我的问题涉及:   http://www.ise.org/sirketler/sirketler.aspx

我正在尝试从上面的 URL 中给出的表格中获取有关证券和公司的所有数据,该 URL 是土耳其伊斯坦布尔证券交易所的网站。

该数据在根据公司名称开头的字母分类的网格表中给出,并且每个网格最多给出 10 行,如您所见。另外,在页面的右下角,写着此信息传播了多少页。

例如,您可以从 Firebug 控制台调用:

__doPostBack('ctl00$cphContent$ctl00$lbtnT','')

来获取以“T”开头的公司,并且您可以通过

__doPostBack('ctl00$cphContent$ctl00$radGridSirketler$ctl00$ctl03$ctl01$ctl05','')
__doPostBack('ctl00$cphContent$ctl00$radGridSirketler$ctl00$ctl03$ctl01$ctl07','')
__doPostBack('ctl00$cphContent$ctl00$radGridSirketler$ctl00$ctl03$ctl01$ctl09','')

分别针对该表的第一页、第二页和第三页发出:等来浏览这些表的选项卡。

我尝试通过对给定的字母和数字数组发出 __doPostBack() 方法来序列化它,方法是将它们连接到上面的固定字符串,但没有成功。

那么我如何使用 __doPostBack() 方法并附加所有这些生成的子表并获取总体数据?

是否有此类任务的资源可供阅读?

对于所有 JS 黑客提出的业余问题,我深表歉意。

I'm coming from a scientific computation background and do have some history with some popular and non-popular (ad hoc) programming languages but I'm completely alien to client side programming and JavaScript.

I've written some trivial JavaScript for my Greasemonkey settings before but that's all.

My question concerns:   http://www.ise.org/sirketler/sirketler.aspx

I'm trying to get all the data about securities and companies from the table given in the URL above which is the site of Turkish İstanbul Stock Exchange.

This data is given within a grid table classified according to the letters which the name of the company begins and at a maximum of 10 rows per grid is given as one can see. Also in the bottom right of the page, there writes how many pages is this info is spread.

For example, you can call from the Firebug console:

__doPostBack('ctl00$cphContent$ctl00$lbtnT','')

for getting the companies starting with 'T' and you can browse the tabs of these table by issuing:

__doPostBack('ctl00$cphContent$ctl00$radGridSirketler$ctl00$ctl03$ctl01$ctl05','')
__doPostBack('ctl00$cphContent$ctl00$radGridSirketler$ctl00$ctl03$ctl01$ctl07','')
__doPostBack('ctl00$cphContent$ctl00$radGridSirketler$ctl00$ctl03$ctl01$ctl09','')

etc. for 1st, 2nd and 3rd pages of this table respectively.

I've tried to serialize this by issuing __doPostBack() method for a given array of letters and numbers by concatenating them to the fixed string above but it did not succeed.

So how can I use __doPostBack() method and append all of these resulting sub tables and get the overall data?

Is there a resource to read for such kind of tasks?

I apologize for my amateur question from all JS hackers.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

被你宠の有点坏 2024-10-07 03:42:24

希望这个例子能启发你的道路:

// ==UserScript==
// @name           Examples : sirketler
// @namespace      http://gm.wesley.eti.br/examples
// @description    Simulation of an aspx PostBack request
// @include        http://www.ise.org/sirketler/sirketler.aspx
// @require        http://userscripts.org/scripts/source/63808.user.js
// @require        http://userscripts.org/scripts/source/89515.user.js
// ==/UserScript==

AspxPostBackRequest({
    "url" : "http://www.ise.org/sirketler/sirketler.aspx",
    "manager" : "ctl00$ScriptManager1",
    "eventTarget" : "ctl00$cphContent$ctl00$lbtnT",
    "callback" : function(xhr)
    {
        var content = document.createElement("div");
        content.innerHTML = xhr.responseText.split("|")[3];

        alert(xpath("./div/table/tbody/tr", content).map(function(row)
        {
            return [].slice.call(row.cells).map(function(col)
            {
                return col.textContent.replace(/^\s+|\s+$/gm, "");
            });
        }).join("\n"));
    }
});

Hopefully this example will enlighten your path:

// ==UserScript==
// @name           Examples : sirketler
// @namespace      http://gm.wesley.eti.br/examples
// @description    Simulation of an aspx PostBack request
// @include        http://www.ise.org/sirketler/sirketler.aspx
// @require        http://userscripts.org/scripts/source/63808.user.js
// @require        http://userscripts.org/scripts/source/89515.user.js
// ==/UserScript==

AspxPostBackRequest({
    "url" : "http://www.ise.org/sirketler/sirketler.aspx",
    "manager" : "ctl00$ScriptManager1",
    "eventTarget" : "ctl00$cphContent$ctl00$lbtnT",
    "callback" : function(xhr)
    {
        var content = document.createElement("div");
        content.innerHTML = xhr.responseText.split("|")[3];

        alert(xpath("./div/table/tbody/tr", content).map(function(row)
        {
            return [].slice.call(row.cells).map(function(col)
            {
                return col.textContent.replace(/^\s+|\s+$/gm, "");
            });
        }).join("\n"));
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文