1

I am learning JavaScript and what I want to do is search for keywords from a text-based website, given a URL.

An example website would just contain text like:

"a" : "nice"
"b" : "nope"
"a" : "try again"
"c" : "whatever"

Where I'd just like to find "a" and store what it is connected to. What should I look for in JavaScript that would let me do something like this?

Another example of "text-based" website: http://graph.facebook.com/zuck

3
  • When you say text based, do you mean preformatted text? or is the text inside of (X)HTML tags (presumably form)? Commented Feb 27, 2011 at 8:58
  • I am meaning something like this: graph.facebook.com/zuck Commented Feb 27, 2011 at 8:59
  • 1
    That looks more like a JSON response. JSON can be easily parsed in JavaScript. How do you access these "websites" from your JavaScript? Commented Feb 27, 2011 at 9:00

2 Answers 2

1

That is JSON using the GRAPH api from facebook - However you need to use the facebook API to get at it here is a tutorial

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

3 Comments

In your example, person is not JSON. It is a JavaScript object. And how is this related with the query string?
Sheez - purist ;) Fixed it now
So how exactly can I get this JSON object? Say for the example above, I had the URL: graph.facebook.com/zuck. How easy would it to find "first_name" and store "Mark"?
0

The content you want to parse is so called JSON. You can parse JSON either using eval() (not advised) or some library (there are plenty of them).

The bigger problem is how are going to get this data? If you want to load this script directly from Facebook, you can't use AJAX because of same origin policy.

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.