Bookmarklet 从当前页面提取数据,然后将其注入远程页面

发布于 2024-08-19 14:18:57 字数 714 浏览 4 评论 0原文

我正在使用一个脚本,该脚本可以正确地从我当前查看的页面中抓取数据。现在我需要知道允许我将这些值注入(并提交)到不同页面上找到的表单中的语法。

小书签的代码:

javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);var%20s=document.createElement('script');s.setAttribute('src',%20'http://juststeve.com/test.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);

可以运行: http://juststeve.com/testData.htm 需要将其注入表单: http://juststeve.com/testform.htm

谢谢

I'm working with a script that is scraping data from my currently viewed page correctly. Now I need to know the syntax that lets me inject (and submit) those values into a form found on a different page.

code for the bookmarklet:

javascript:var%20s=document.createElement('script');s.setAttribute('src',%20'http://jquery.com/src/jquery-latest.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);var%20s=document.createElement('script');s.setAttribute('src',%20'http://juststeve.com/test.js');document.getElementsByTagName('body')[0].appendChild(s);void(s);

can run against: http://juststeve.com/testData.htm
needs to inject it to the form: http://juststeve.com/testform.htm

thankx

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

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

发布评论

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

评论(2

音盲 2024-08-26 14:18:57

由于您似乎使用 jQuery 来执行数据收集和提交,因此您应该首先检查 jQuery 文档。在那里,您将了解如何使用 $.ajax提交数据(使用data参数)。

简而言之,您要做的就是替换

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this"  },

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this", "orderDate": orderDate, "email": email, "customerID": customerID },

AJAX POST 请求将在请求中向服务器提供 3 个额外参数,其中包含我猜测您想要提交的值。您如何处理在服务器端检索此类值将取决于您正在使用的服务器端语言/堆栈。

Since you seem to be using jQuery to perform the data harvesting and submission, you should first check the jQuery documentation. There you'll find how to use $.ajax to submit data (using the data parameter).

In short, what you have to do is replace

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this"  },

with

data: { formkey: "Fd0SHgwQ3YwSFd5UHZpM1QxMlNOdlE6MA", entry_0: "this", "orderDate": orderDate, "email": email, "customerID": customerID },

meaning that the AJAX POST request will give the server 3 extra parameters in the request with the values I'm guessing you want to submit. How you deal with retrieving such values in the server side will depend on the server side language/stack you're using.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文