douyimiao1993 2016-03-15 05:34
浏览 99
已采纳

加载外部页面和替换文本

Would it be possible to load an external page inside a container and replace text elements?

We work with ad campaigns and earn a percentage whenever a user signs up.

Can a script replace certain words? For instance “User” to “Usuario” or “Password” to “Contraseña” without affecting the original website or its functions.

Note: These links always pass through a redirection.

Example:

http://a2g-secure.com/?E=/0yTeQmWHoKOlN6zUciCXQwUzfnVGPGN&s1=

Note 2: Using an iframe is out of the question due to “Same-origin policy”.

  • 写回答

5条回答 默认 最新

  • dongyi9082 2016-03-19 20:17
    关注

    I'm not sure if this answers your question, but you might find it useful.

    (Perhaps you might give a step-by-step example of what you're trying to accomplish?)

    If we assume that a browser attempts to retrieve page P from a proxy which first retrieves the content of page P from its actual home and then performs some transformation on its content before returning that page content to the browser, what you're describing is a Reverse HTTP Proxy and is a very well-known page serving technique.

    Rather than performing complex transformations at the server (which require specialized knowledge of the page layout), this technique is usually used to inject a single line into the retrieved source that calls a JavaScript file to actually perform the required transformation at the browser.

    So in essence:

    1. Browser requests Page P from Proxy 1.
    2. Proxy 1 retrieves the actual Page P from its real home, Server 2.
    3. Proxy 1 adds the line <script src="//proxy1.com/transform.js"></script> to the source of Page P.
    4. Proxy 1 then returns the modified source of Page P to Browser.

    Once the Browser has received the page content, the JavaScript file is also retrieved, which can then modify the page contents in any way required.

    This technique can be used to solve your "Same origin policy" issue by loading an iframe from a URL that points to the same server as that which provided the parent or owning page of the iframe which acts as proxy, like:

    http://example.com/?proxy_target=//server2.com/pageP.html
    

    Thus, the browser only "sees" content from a single server.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 脱敏项目合作,ner需求合作
  • ¥15 脱敏项目合作,ner需求合作
  • ¥30 Matlab打开默认名称带有/的光谱数据
  • ¥50 easyExcel模板 动态单元格合并列
  • ¥15 res.rows如何取值使用
  • ¥15 在odoo17开发环境中,怎么实现库存管理系统,或独立模块设计与AGV小车对接?开发方面应如何设计和开发?请详细解释MES或WMS在与AGV小车对接时需完成的设计和开发
  • ¥15 CSP算法实现EEG特征提取,哪一步错了?
  • ¥15 游戏盾如何溯源服务器真实ip?需要30个字。后面的字是凑数的
  • ¥15 vue3前端取消收藏的不会引用collectId
  • ¥15 delphi7 HMAC_SHA256方式加密