/    Sign up×
Community /Pin to ProfileBookmark

Scanning a page for certain elements

I’m new to javascript but am beginning to implement my ideas from scratch rather than fiddle with existing code.

I have thought of an application which would require the script to look at a page which would be outside the domain from which my script resides.

I want it to scan through this page, look for <a> elements with specific classes on them, and store the text in between these <a> tags in an array.

From then on I would be clear on what to do.

If this sounds possible, could you point me in the right direction to achieve this?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@slaughtersJan 14.2009 — JavaScript can not do this.

Do a Google search on page or screen "scraping" for some server side answers.
Copy linkTweet thisAlerts:
@mrhooJan 14.2009 — You'll need to read files that are not in your domain with a script on the server, javascript alone can only read local files.
Copy linkTweet thisAlerts:
@voidvectorJan 14.2009 — Website-based JavaScript is not allowed to access content from another website. This is done to prevent exploits using cross-site scripting.

Say you recently visited your banking website, and forgot to log off, if this cross-site security wasn't in place, there will be nothing to stop a malicious website from displaying your bank's website in a frame and grab all your credentials.
Copy linkTweet thisAlerts:
@ThomasWauthorJan 14.2009 — yeah I had a feeling this might be the case I guess the security implications would be ridiculous if javascript could do this, im turning to PHP for screen scraping methods now.
×

Success!

Help @ThomasW spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...