简体   繁体   English

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

[英]How to write a Greasemonkey script to handle __doPostBack()

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. 我来自科学计算背景,并且确实有一些流行和不流行的(即席)编程语言的历史,但是我完全不了解客户端编程和JavaScript。

I've written some trivial JavaScript for my Greasemonkey settings before but that's all. 我之前为Greasemonkey设置编写了一些琐碎的JavaScript,仅此而已。

My question concerns: http://www.ise.org/sirketler/sirketler.aspx 我的问题涉及: 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. 我正在尝试从上面的URL(土耳其伊斯坦布尔证券交易所的网站)中给出的表格中获取有关证券和公司的所有数据。

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. 该数据在网格表中给出,该网格表根据公司名称开头的字母进行分类,每个网格最多可以看到10行。 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: 例如,您可以从Firebug控制台调用:

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

for getting the companies starting with 'T' and you can browse the tabs of these table by issuing: 为使公司以“ 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','')

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. 我尝试通过将给定的字母和数字数组连接到上面的固定字符串来发出__doPostBack()方法来序列化此序列,但是没有成功。

So how can I use __doPostBack() method and append all of these resulting sub tables and get the overall data? 那么,如何使用__doPostBack()方法并附加所有这些结果子表并获取整体数据?

Is there a resource to read for such kind of tasks? 是否有阅读此类任务的资源?

I apologize for my amateur question from all JS hackers. 对于所有JS黑客的业余问题,我深表歉意。

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"));
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM