Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2010
    Thanked 0 Times in 0 Posts

    Question Getting values of H1 tag based on URL

    Below is the code I'm using.
    Essentially I need the values stored within the H1 tag based on the URL, I don't know how to get that value or if it has to be scraped.

    FYI the url needed to retrieve h1 tag data can be considered a cross domain.

    Little guide on the mechanics of the form.

    1. type model number in first box
      second box retrieves the value within h1 tag
      Image is shown based on which model number is typed in first box

    Appreciate any and all kinds of help.
    Thank You

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <form name="form1" method="post" action="">
           <p>7-digit product#
             <input type="text" name="model" id="model">
             <label for="description">description</label>
             <input type="text" name="description" id="description">
             <input name="start" type="hidden" id="start" value="http://www.mysite.com/Products/">
             <input name="end" type="hidden" id="end" value=".jpg">
           <p><img name="proudctimage" src="=#start#model#end" width="32" height="32" alt=""></p>
        var model_input = document.getElementById('model');
        var start = document.getElementById('start');
        var end = document.getElementById('end');
        var image = document.getElementsByTagName('img');
        model_input.onkeyup = function(e){
           image[0].src = start.value + model_input.value + end.value; }

  2. #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    Can't do it. You can't cross-domain screen scrape using JavaScript. Oh, there are ways to do it *IF* you can put code into the pages on BOTH domains, but not if you have no control over the foreign domain's pages.

    You *can* do this using server-side code: PHP/ASP/JSP/etc.
    Be yourself. No one else is as qualified.

  3. #3
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Thanked 665 Times in 660 Posts
    if you're really set on client-side you could maybe do it using something like the yahoo ypl - which is the page you want to scrape and where is the H1?


Tags for this Thread

Posting Permissions

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