admin管理员组

文章数量:1291093

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

open

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 ";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?

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

open http://www.ocwconsortium/#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./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?

Share Improve this question edited Apr 26, 2009 at 23:50 Léo Léopold Hertz 준영 asked Apr 26, 2009 at 22:52 Léo Léopold Hertz 준영Léo Léopold Hertz 준영 141k189 gold badges465 silver badges713 bronze badges 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. – Wouter van Nifterick 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 mand at the shell prompt and have it display the "results"? – Van Gale 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 bees 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? – Léo Léopold Hertz 준영 Commented Apr 26, 2009 at 23:38
Add a ment  | 

5 Answers 5

Reset to default 3
open "http://www.ocwconsortium/index.php?q=mathematics&option=_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.

The Links web browser more or less runs from the mandline (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 mandline (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.

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

http://www.ocwconsortium/index.php?q=mathematics&option=_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.

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

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

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

本文标签: How can I execute javascript in BashStack Overflow