Results 1 to 6 of 6

Thread: [JavaScript] Get elements by class from external site

  1. #1

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    [JavaScript] Get elements by class from external site

    I'm wanting to know if it's possible to get all elements from an external website using JavaScript. Everything that I've read online seems to conflict each other.

    Basically what I'm wanting to do is get the innerHTML from all elements who's class name is forumtitle on http://www.vbforums.com/forum.php. It doesn't necessarily have to be JavaScript, it's just that is what I'm comfortable with.

    Also, I wanted to let y'all know that I've triple checked the AUP and it looks like what I'm doing is OK.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  2. #2
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: [JavaScript] Get elements by class from external site

    I'm guessing you will get blocked by Same Origin Policy in the browser if you go the JavaScript route. If you're scraping pages with a server-side or fat-client app, you wouldn't have those restrictions.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  3. #3
    Frenzied Member tr333's Avatar
    Join Date
    Nov 2004
    Location
    /dev/st0
    Posts
    1,605

    Re: [JavaScript] Get elements by class from external site

    You would need CORS enabled on the server-side to get past the SOP restrictions.
    CSS layout comes in to the 21st century with flexbox!
    Just another Perl hacker,

  4. #4

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: [JavaScript] Get elements by class from external site

    I will take a look at CORS specification and post back here on my progress.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

  5. #5
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: [JavaScript] Get elements by class from external site

    If you're simply looking to get the elements, and some value in them, but not actually manipulate them, you could simply scrape the source (using C#, python, etc) and use regex to parse out fields that have the class name you indicated.
    Last edited by kfcSmitty; Sep 10th, 2014 at 08:07 AM.

  6. #6

    Thread Starter
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Location
    South Louisiana
    Posts
    11,711

    Re: [JavaScript] Get elements by class from external site

    Yeah, I'm not wanting to manipulate them. Only get the text of the forum's title. I found this website and I'm going to read up on that article.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | Code Tags | Sword of Fury - Jameram

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width