As we discussed on chat, the code pasted below solves the problem (almost
). It relies on using multiple instances of the "site:" operator, separated by ORs. Since a single search can have a limited number of terms, searching 300 sites is not possible in one go and needs to be divided into categories.
The code includes two sample categories, technical sites and how to sites. More categories can be added in a similar way, although it will be better if a separate function is created for this purpose.
The lists of sites need to be specified in the array variables at the beginning of the script. Since Google allows a maximum of 32 search words, the number of sites should be 31 or less in each category, assuming a single search term. So, 300 sites will require more than 10 categories.
HTML Code:
<html><head>
<script type="text/javascript">
var techSites = ['tech-faq.com', 'systemdisc.com', 'symatech.net', 'iqio.org', 'rolo.org', 'explaintechstuff.com']; // add other sites
var howToSites = ['ihowd.com', 'iaskd.com', 'howtodothesethings.com', 'bestinlife.net']; // add other sites
var techString="";
if (techSites.length > 0)
{
techString = " site:" + techSites[0];
for (var i=1; i<techSites.length; i++) {
techString += " OR site:" + techSites[i];
}
}
var howToString="";
if (howToSites.length > 0)
{
howToString = " site:" + howToSites[0];
for (var i=1; i<howToSites.length; i++) {
howToString += " OR site:" + howToSites[i];
}
}
function submitTechForm() {
open("http://www.google.com/search?q=" + document.getElementById("techTextBox").value + techString + "&lr=lang_en");
}
function submitHowToForm() {
open("http://www.google.com/search?q=" + document.getElementById("howToTextBox").value + howToString + "&lr=lang_en");
}
</script>
</head><body>
<form action="javascript:submitTechForm()">
<input name="q" id="techTextBox" type="text"><input value="Search Tech Sites!" type="submit">
</form>
<form action="javascript:submitHowToForm()">
<input name="q" id="howToTextBox" type="text"><input value="Search How To Sites!" type="submit">
</form>
</body></html>
Hope that helps!
Bookmarks