Long-term infection with hepatitis B or C is the main cause of liver cancer. Hepatitis B and C are spread through blood or sexual contact.