Archive for the 'Coding' Category

Scraping 101: Extracting Anchor Text with Regexp • Friday, February 8th, 2008

There are many ways to skin a cat, but when it comes to scraping websites, I like parsing content with regexp. One of the biggest problems I bumped into when parsing HTML is matching opening and closing tags.
For example:
(<a [^>]+>)(.*)</a>
Ok let’s try that in English:

(<a [^>]+>) matches <a href=”….”.>.
(.*) *should* match anchor text (I’ll […]


JDBC ClassNotFoundException (NetBeans, Classpath, Java) • Saturday, June 16th, 2007

If you get a java.lang.ClassNotFoundException error when loading a database driver using the statement:
Class.forName({nameOfYourDriverWhateverItIs}).newInstance();
You can either:
Set CLASSPATH in DOS
Go into DOS (Start/Run/cmd.exe):
set CLASSPATH=.;{pathToYourJarFile}
For example, if your jar file is at: C:/Program
Files/java/jdk1.6.0_01/lib/mysql-connector-java-5.0.6-bin.jar,
Type:
set CLASSPATH=.;C:/Program Files/java/jdk1.6.0_01/lib/mysql-connector-java-5.0.6-bin.jar
Now,
javac YourJavaFile.java
java YourJavaFile
That’s all. But it won’t work if you’re trying to run code in Netbeans.
Set Your Project’s Classpath in Netbeans
If you’re using […]