...

View Full Version : Getting values of H1 tag based on URL



kmpoaquests
05-29-2012, 06:28 PM
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.


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


<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head><body>

<form name="form1" method="post" action="">
<p>7-digit product#
<input type="text" name="model" id="model">
</p>
<p>
<label for="description">description</label>
<input type="text" name="description" id="description">
</p>
<p>
<input name="start" type="hidden" id="start" value="http://www.mysite.com/Products/">
</p>
<p>
<input name="end" type="hidden" id="end" value=".jpg">
</p>
<p><img name="proudctimage" src="=#start#model#end" width="32" height="32" alt=""></p>
</form>

<script>
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; }
</script>

</body>
</html>

Old Pedant
05-29-2012, 10:20 PM
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.

xelawho
05-29-2012, 10:31 PM
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?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum