PDA

View Full Version : Improting Posts when only some have URLS - FIX


rgordon83
02-03-2009, 03:21 PM
Ok, so if you are scraping from Yellow Pages you may find that not all listings have websites. But for the ones that do, you may want to set up your post template so that you can make them clickable hyperlinks.

Only problem is for all the blank cells with no URL you will get HTML for a url, but with no actual URL. That can't be god for SEO.

So here's what i did.

First make your template so it calls in the website URL. since yellowpage listings don't have the "http://", we'll add it:

<a href="http://[website]" target="_blank" />[website]</a>
that will call in the website so it is clickable and opens in a new window.

But the problem is for all the posts with no url, your post will have this:

"<a href="http://" target="_blank" /></a>"

and that's bad.

But as far as i know, there is know easy way to bulk edit the HTML in wordpress posts. So we're gonn do in in phpMyAdmin.

So to your phpMyAdmin and find your wordpress database. then click the "Browse" icon next to WP_posts field.

Then click "export" at the top of the page. On the export page tick off the "Add drop table" box and export as a ,sql file.

Copy the file and paste into your favorite text editor. I use textWrangler (http://www.barebones.com/products/textwrangler/)

Do a ctrl F and replace <a href="http://" target="_blank" /></a> with nothing. that will delete them all. Save the file as a .sql

Go back to your phpMyAdmin screen and click "import" link at the top. upload the file.

Say "Presto Chango" 5 times and Whalla! all your posts without links are good to go!

nickmattern
02-05-2009, 07:41 AM
RG,

I'm writing a desktop application to bypass a lot of these issues.

First, I hate the 2K limit, but try as we could, we couldn't get around the memory limitations of PHP. It works like a crazy horse with less than 1K records, but if you have 25K businesses, you're wasting a lot of time getting it chunked up for import.

The desktop tool will run client-side. For now, it'll be windows only, unless some java developer wants to donate some time!

It'll handle "IF" routines in the post import. For example, you have 1000 businesses in your CSV, but only 500 have web addresses.

POST:
Name: [Name]
City: [City]

{if:[Website] (
Website: [Website]
)}

END POST

So if the Website field has a value for that record, it posts "Website: www.blah.com", if no website value, then the field doesn't print on the post.

What else would you guys like to see this do?