1

I am trying to extract the html source of this page, http://www.fxstreet.com/rates-charts/currency-rates/

I want what I see when I save the page from chrome as a .html file.

I tried to do this in java, using bufferedreader, and then using jsoup. I also tried to do it in python, however I keep getting the following message:

"This site requires JavaScript and Cookies to be enabled. Please change your browser settings or upgrade your browser."

The end goal is to extract the values in the main table.

2
  • It seems to be in Flash or something. Commented Jun 2, 2012 at 6:39
  • Xeon was right. It works fine with HtmlUnit, with JS enabled. Commented Jun 8, 2012 at 18:15

2 Answers 2

4

Try using HtmlUnit and setting setJavascriptEnabled(true)

Look also at: this and this

JSoup isn't headless browser to execute Javascript so you must choose other library to get the page and then you can use JSoup to parse it.

Sign up to request clarification or add additional context in comments.

Comments

1

Just to extract the main table can be easily done using Jsoup

here's a method that will take all the content from the main table on the page

public void parse(){
        try{

        Document doc = Jsoup.connect("http://www.fxstreet.com/rates-charts/currency-rates/").get();
        Element content = doc.getElementById("ddlPairsChoose");
        Elements table = doc.getElementsByClass("applet-content");      

        System.out.print(table);

        }

        catch(Exception e){

            System.out.print("error --> " + e);
        }       
    }

It prints out the table on the page

1 Comment

Like this too, as Jsoup can simulate a browser quite well if you use the connect mechanism. If this wont work either, run a local http proxy and browse the site manually recording the communication. Perhaps the Browser sends additional AJAX background requests to filter out robots or the site requires different user agents (then check this: stackoverflow.com/questions/6581655/…)

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.