3

I try to get to a page straight from Bash at http://www.ocwconsortium.org/. The page appears when you write mathematics to the field at the top right corner. I tested

open http://www.ocwconsortium.org/#mathematics

but it leads to the main page. It is clearly some javascript thing. How can I get the results straight from Bash on the first page?

[Clarification]

Let's take an example. I have the following lines for a Math search engine in .bashrc:

alias mathundergradsearch='/Users/user/bin/mathundergraduate'

Things in a separate file:

#!/bin/sh                                                                                                                                                                     

q=$1
w=$2
e=$3
r=$4
t=$5

open "http://www.google.com/cse?cx=007883453237583604479%3A1qd7hky6khe&ie=UTF-8&q=$q+$w+$e+$r+$t&hl=en"

Now, I want something similar to the example. The difference is that the other site contains javascript or something that does not allow me to see the parameters. How could I know where to put the search parameters as I cannot see the details?

3
  • You should add a bit more information about what you're trying to achieve. Else you probably won't get any answer that is helpful to you. Commented Apr 26, 2009 at 23:08
  • 1
    Please clarify your question. Which "results" are you looking for? The list of courses? The links to the courses? And, getting the results "from" bash I assume you mean you want to type a command at the shell prompt and have it display the "results"? Commented Apr 26, 2009 at 23:15
  • Van Gale: Your suggestion is more than perfect. It would be very cool to see "the list of courses" and "the links to the courses", side by side in CLI. For the beginning, I am though glad if I even get the page opening to me. Then, your option becomes more tangible. I was planning something like your idea, but I tried to keep the question specific. How can I see the search results of some courses? Commented Apr 26, 2009 at 23:38

5 Answers 5

3
open "http://www.ocwconsortium.org/index.php?q=mathematics&option=com_coursefinder&uss=1&l=&s=&Itemid=166&b.x=0&b.y=0&b=search"

You need quotes because the URL contains characters the shell considers to be special.

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

4 Comments

Very cool! How did you know the parameters such as "com_coursefinder" and "166" in Itemid?
I search for mathematics in the search bar and then copied the URL, what browser are you using?
On Firefox, the full URL with the parameters shows up in the address bar. Not sure if YMMV on another browser.
Single quotes would be better there, because double-quotes can still be expanded by bash.
3

The Links web browser more or less runs from the commandline (like lynx) and supports basic javascript.

Even though the title of the post sounds general, your question is very specific. It's unclear to me what you're trying to achieve in the end. Clearly you can access sites that rely heavily on javascript (else you wouldn't be able to post your question here), so I'm sure that you can open the mentioned site in a normal browser.

If you just want to execute javascript from the commandline (as the title suggests), it's easy if you're running bash via cygwin. You just call cscript.exe and provide a .js scriptname of what you wish to execute.

1 Comment

I am interested. Can you see specific parameters to each site, such as the parameters in the reply by Samir Talwar?
1

I didn't get anything handled by JavaScript - it just took me to

http://www.ocwconsortium.org/index.php?q=mathematics&option=com_coursefinder&uss=1&l=&s=&Itemid=166&b.x=0&b.y=0&b=search

Replacing mathematics (right after q=) should work. You may be able to strip out some of that query string, but I tried a couple of things and and it didn't play nice.

Don't forget to encode your query for URLs.

2 Comments

How were you able to see the parameters? When I do a search, I get only "ocwconsortium.org/#key_word"
The URL in the location bar changed to that, but then the page was redirected to the URL above. I'm not sure what's different between my browser configuration and yours - I'm using Firefox, and I have JavaScript turned on.
0

You will need to parse the response, find the URL that is being opened via JavaScript and then open that URL.

Comments

0

Check this out: http://www.phantomjs.org/.

PhantomJS it's a CLI tool that runs a real, fully-fledged Browser without the Chrome.

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.