SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Evangelist artcoder's Avatar
    Join Date
    Aug 2005
    Location
    Planet Earth
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript to scrape a page

    How to I write a Javascript to call an URL like ...

    http://webservices.imacination.com/d...94132&x=25&y=4

    And then get the "view source" into a string variable. I then want to parse the string variable to get the answer found on that page which is the distance between two zip codes.

    Also I want people's opinion as to whether this is permissible. For example, this URL is labeled as a Free Web Services. And I did not see any notices forbidding such action. Plus the Javascript is only invoked when a user hits a button, so this is not a continuously automated query. The scraped data is not store nor republished.

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,608
    Mentioned
    24 Post(s)
    Tagged
    1 Thread(s)
    It depends on which side language are you going to use to retrieve the page that you want to display the source for as to how you code the processing that you do the ajax call to that does the retrieval. It can't be done entirely with just JavaScript because JavaScript has no access to other domains.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">


Bookmarks

Posting Permissions

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