0

I am making a request and reading the HTML content. The problem is that 90% of the content is JavaScript. How can I make the request and not get the JavaScript?

You can see here that CurrentHtml (the contents of the response) has JavaScript that contains elements that I need:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <script type="text/javascript" src="js/jwplayer.js"></script>
        <script type="text/javascript">         jwplayer.key = "5yP+phROWS+QiNQny92l2iTFqbmzhyI/mT+Zsw==";</script>
        <script type="text/javascript" src="js/kyop_mock.js"></script>
        <script id="kyop-header" type="text/x-jquery-tmpl">         
            <img class="left" src="${verticalBar}" />
            <img class="logoCabecera" src="${logo}" />
            <div class= "clearAll"></div>
        </script>

        <script id="kyop-links" type="text/x-jquery-tmpl">
            {{each(index, adContent) contentTop}}
                <span class="enlacesWrapper">
                    {{if document != null}}
                          <span><a target="_blank" href="${document.fileUrl}" title="${contentTittle}" ratittle="${ratittle}" rapage="${rapage}">${contentTittle}</a></span>
                   {{else}}
                        {{if link != null && link != ""}}
                           <span><a onclick="showModalWindow('#kyop-modal-${index}');" title="${contentTittle}" ratittle="${link.ratittle}" rapage="${link.rapage}">${contentTittle}</a></span>
                           <div id="kyop-modal-${index}" class="kyop-container-ventanaModal" style="display: none;">
                                <div class="ventanaModal">
                                    <div class="right">
                                        <img src="img/cerrarGrandeAzul.png" onclick="closeModalWindow('#kyop-modal-${index}')" style="cursor: pointer; cursor: hand; padding-bottom: 6px;">
                                    </div>  
                                    <div>
                                        <iframe class="kyop-modal-iframe" src="${link.linkUrl}" frameBorder="0"></iframe>
                                    </div>                      
                                </div>
                                <div class="fondoTransparente"></div>
                            </div>
                        {{else}}
                            <span><a title="${contentTittle}" ratittle="${ratittle}" rapage="${rapage}">${contentTittle}</a></span>
                        {{/if}}
                   {{/if}}
                   {{if contentIcon != null && contentIcon != ""}}
                       <img src="${contentIcon}" />
                   {{/if}}
                   <div class="clearAll"></div>
                </span>
            {{/each}}
        </script>


    </head>
    <body>
        <div id="cajacentral" class="kyop_cajacentral" >
            <div id="cabecera" >                    
            </div>

            <div id="pie">
                <div id="pie_derecha">                  
                </div>
                <div id="pie_izquierda">
                    <b>&copy; BBVA S.A.</b> 
                </div>
                <div class="clearAll"></div>
            </div>
        </div>
    </body>
</html>

2 Answers 2

1

When you get a Page Source you will get everything which is on the page, that's obvious.

There are 2 things you can do!

  1. Remove Javascript from main page and put in a .Js file and reference it on your HTML, so you will finally receive a html with just single line
  2. Remove Javascript tag from HTML after you receive response

Something like this

 node.parentNode.removeChild(node);
Sign up to request clarification or add additional context in comments.

Comments

0

you can't request a page without JS from a server separately. because it's a file that the server send to clients. unless there is a web service that make it to you. but you can parse the HTML file and clear JS tags easily.

a wonderful parser

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.