Замена ссылок в скрипте
Задача простая, но точно не для меня) Необходимо с одного сайта с помощью javascript скопировать часть кода. В принципе ответ уже есть Вот скрипт:
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <script src="http://code.jquery.com/jquery-latest.js"></script> <script>jQuery.ajax = function (d) { var b = location.protocol, e = RegExp(b + "//" + location.hostname), f = "http" + (/^https/.test(b) ? "s" : "") + "://query.yahooapis.com/v1/public/yql?callback=?"; return function (a) { var c = a.url; if (/get/i.test(a.type) && !/json/i.test(a.dataType) && !e.test(c) && /:\/\//.test(c)) { a.url = f; a.dataType = "json"; a.data = { q: 'select * from html where url="{URL}" and xpath="*"'.replace("{URL}", c + (a.data ? (/\?/.test(c) ? "&" : "?") + jQuery.param(a.data) : "")), format: "xml" }; !a.success && a.complete && (a.success = a.complete, delete a.complete); var b = a.success; a.success = function (a) { b && b.call(this, { responseText: (a.results[0] || "").replace(/<script[^>]+?\/>|<script(.|\s)*?\/script>/gi, "") }, "success") } } return d.apply(this, arguments) } }(jQuery.ajax);</script> <script> (function ($) { $(function () { $.ajax({ url: 'http://www.kitco.com/', type: 'GET', success: function(res) { var tab = $(res.responseText).find('.market_time'); $("body").append(tab); } }); } ) } )(jQuery) </script> </head> <body> please wait </body> </html> (javascript.ru/forum/dom-window/21288-nuzhna-pomoshh-s-ochen-prostymi-veshhami-3.html) правда хотелось бы при этом удалять все ссылки на чужие страницы из этого кода с заменой на свою)) Прошу помощи, заранее благодарю за ответы)) К сожалению не разбираюсь в js, буду признателен за конкретный пример) |
Часовой пояс GMT +3, время: 15:48. |