Some Classic ASP in VBScript and SQL Server tips, flavored with rhetorical rants, commentary and other useless blather.

Thursday, September 07, 2006

Scraping Search Engines for Page Content

It's no secret that optimized page content can help you rank better in organic search engine results. While page content is not the deciding factor, it's stil important, especially for long tail search terms. No matter what your page content, you're probably not going to be able to rank well for the term 'dvd player' (or any other exceptionally competetive term). But you might be able to rank on a long tail term such as 'panasonic portable dvd player model 123ABCxyz'. For such a long tail phrase, optimized page content can help.

But how to get the content? Well, you could write it. Or buy it. Or... scrape it from somewhere else.

If you chose the scraping solution, I highly recommend that you have some original content on the page. Write a capsule review, or your own description, or anything else that likely doesn't exist on some other site (until, of course, someone scrapes it).

The following process will step you through scraping content from a search engine and adding it to your page.

WARNING: Implementing these techniques could very well get you banned from the search engines!

1. Decide on the keyword you want to generate content for. For this example, I'll use the fictitious Panasonic DVD model from above.

2. Decide how many search engines you're going to scrape content from. For this example, I'll use 3: MSN, Yahoo, and Gigablast.

4. Now pass the number into a page scraping function to go out and get the search results for that phrase from the search engine. The way you might do it is pass the number and keyword into the function:

6. Now that you have the body content, replace all the breaks with a space; this is because words might run to gether otherwise:

strContent = Replace(strContent,"<br>"," ")

7. There are some extraneous words that have no relevancy to your search term that you're probably going to want to strip out as well. For example, Yahoo has additional links that follow the listing: 'Cached', 'More from this site', 'Save' etc. I recommend customizing a function to strip out all the non keyword related carp that clutters the search results you just scraped.

8. Now you have fairly clean copy relevant to your keyword, the last thing to do strip out the HTML.

The end result: a big chunk of text directly relevant to your keyword.

There's a few things you can do with it: plop it right on the page (not recommended), hide it in a div, or - my recommendation - hide it in a div and reverse cloak it, so that only search engines can see it. Hopefully your pages will start climbing higher in the organic results.

Leverage those favorable results quickly! Sooner or later you'll find your site banned, either because the spiders got smarter or a competitor reported you.