zsh-users
 help / color / mirror / code / Atom feed
* How to parse JavaScript from Zsh?
@ 2013-11-01  2:52 TJ Luoma
  2013-11-01  2:59 ` Thiago Padilha
  2013-11-01  3:04 ` Abhijeet Rastogi
  0 siblings, 2 replies; 4+ messages in thread
From: TJ Luoma @ 2013-11-01  2:52 UTC (permalink / raw)
  To: Zsh-Users List

Long story short… my home network is satellite Internet. It has a
20gb/month quota (not a typo). I used to be able to parse the output
of http://192.168.0.1 using `lynx` but they üpgraded their system and
now http://192.168.0.1 uses JavaScript to deliver the information.

I can't figure out how to parse JavaScript from a Zsh script.

Ok, I admit that this is skirting on the edge of Zsh here, but I've
been googling for a couple hours and don't seem to be finding anything
close to a solution. Maybe just haven't found the right keywords, but
I'm getting a ton of unrelated crap.

I'm guessing there's some tool out there like `lynx` or `wget` or
`curl` which can parse JavaScript from the command line, but I can't
find whatever it is.

So I'm hoping maybe someone here has already reached the top of this
mountain and can point me in the right direction.

TjL


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to parse JavaScript from Zsh?
  2013-11-01  2:52 How to parse JavaScript from Zsh? TJ Luoma
@ 2013-11-01  2:59 ` Thiago Padilha
  2013-11-01  5:58   ` TJ Luoma
  2013-11-01  3:04 ` Abhijeet Rastogi
  1 sibling, 1 reply; 4+ messages in thread
From: Thiago Padilha @ 2013-11-01  2:59 UTC (permalink / raw)
  To: TJ Luoma; +Cc: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 1262 bytes --]

Parsing a complex language like javascript is not the job for a shell
language

Perhaps they are sending just JSON and you mistake with javascript? If its
just json you can try this https://github.com/micha/jsawk it targets bash
but should work with zsh.


On Thu, Oct 31, 2013 at 11:52 PM, TJ Luoma <luomat@gmail.com> wrote:

> Long story short… my home network is satellite Internet. It has a
> 20gb/month quota (not a typo). I used to be able to parse the output
> of http://192.168.0.1 using `lynx` but they üpgraded their system and
> now http://192.168.0.1 uses JavaScript to deliver the information.
>
> I can't figure out how to parse JavaScript from a Zsh script.
>
> Ok, I admit that this is skirting on the edge of Zsh here, but I've
> been googling for a couple hours and don't seem to be finding anything
> close to a solution. Maybe just haven't found the right keywords, but
> I'm getting a ton of unrelated crap.
>
> I'm guessing there's some tool out there like `lynx` or `wget` or
> `curl` which can parse JavaScript from the command line, but I can't
> find whatever it is.
>
> So I'm hoping maybe someone here has already reached the top of this
> mountain and can point me in the right direction.
>
> TjL
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to parse JavaScript from Zsh?
  2013-11-01  2:52 How to parse JavaScript from Zsh? TJ Luoma
  2013-11-01  2:59 ` Thiago Padilha
@ 2013-11-01  3:04 ` Abhijeet Rastogi
  1 sibling, 0 replies; 4+ messages in thread
From: Abhijeet Rastogi @ 2013-11-01  3:04 UTC (permalink / raw)
  To: TJ Luoma; +Cc: Zsh-Users List

[-- Attachment #1: Type: text/plain, Size: 1123 bytes --]

You should perhaps try to sniff the GET/POST request that's being done via
Ajax and get to curl that URL.

- Sent from my Galaxy Note 3
On 1 Nov 2013 08:26, "TJ Luoma" <luomat@gmail.com> wrote:

> Long story short… my home network is satellite Internet. It has a
> 20gb/month quota (not a typo). I used to be able to parse the output
> of http://192.168.0.1 using `lynx` but they üpgraded their system and
> now http://192.168.0.1 uses JavaScript to deliver the information.
>
> I can't figure out how to parse JavaScript from a Zsh script.
>
> Ok, I admit that this is skirting on the edge of Zsh here, but I've
> been googling for a couple hours and don't seem to be finding anything
> close to a solution. Maybe just haven't found the right keywords, but
> I'm getting a ton of unrelated crap.
>
> I'm guessing there's some tool out there like `lynx` or `wget` or
> `curl` which can parse JavaScript from the command line, but I can't
> find whatever it is.
>
> So I'm hoping maybe someone here has already reached the top of this
> mountain and can point me in the right direction.
>
> TjL
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to parse JavaScript from Zsh?
  2013-11-01  2:59 ` Thiago Padilha
@ 2013-11-01  5:58   ` TJ Luoma
  0 siblings, 0 replies; 4+ messages in thread
From: TJ Luoma @ 2013-11-01  5:58 UTC (permalink / raw)
  To: Thiago Padilha; +Cc: Zsh-Users List

On Thu, Oct 31, 2013 at 10:59 PM, Thiago Padilha <tpadilha84@gmail.com> wrote:
> Perhaps they are sending just JSON and you mistake with javascript? If its
> just json you can try this https://github.com/micha/jsawk it targets bash
> but should work with zsh.

Well, this sent me back looking more closely at it… yes, it was
javascript… but the good news is that when I started poking around I
found that the information I wanted was being pulled (via JS) from a
regular HTML page.

So now I'm just parsing that using curl, sed, and tr.

(You can even see it at https://gist.github.com/tjluoma/7260924 if you
want, but I warn you: it's ugly. But it works.)

Thanks!

TjL


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-01  5:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-01  2:52 How to parse JavaScript from Zsh? TJ Luoma
2013-11-01  2:59 ` Thiago Padilha
2013-11-01  5:58   ` TJ Luoma
2013-11-01  3:04 ` Abhijeet Rastogi

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).