It really depends on the class if you need to attend or not.
Language classes? Always.
Economics? Never.
Criminal Justice? Rarely.
English Classes? Always.
Science Classes? Always.
Humanities/Arts? Never.
Obviously sucking up to a teacher helps. Talk to them after class. Read what they've published. Write or make course work about topics they like to discuss or research on.
Obviously it depends on your abilities. You should know from the first week if you need to attend every class, or if you can screw around and only come on test days.
I've been about 5 times to my Econ class this semester. 90% on the first quiz (10 questions, and I missed one), and then a 98% on the Exam (missed one question there, too).
Spanish? If I didn't go to class I'd be screwed. Even though I speak Spanish on a daily basis with my Fiance and friends, it doesn't matter. You don't know the structure and material unless you go. Same with classes like English or Lit. You HAVE to know what the Professor wants, what format they want, and how they want you to phrase your paper or work.
Criminal Justice? I read the book the first week, show up about once every two weeks, and then make A's on the test. Now, that's not all CJ classes. Some can be rough, especially if there are a lot of essays and experts that come in. However, I've had several classes that the tests were easy, and based on prior knowledge, some notes, and the text.
Science classes? You need to go. Even if you are good at the material you need to go to get the professor's perspective. You need to know what they emphasize, and what they gloss over with barely a mention.
Math classes? If you suck at math like me then you better go everytime.
Arts/Humanities/History/Social Sciences, etc... Depends on the class, but most of the time you can miss quite a bit and pull off an A or B.