The DataFrame. to csv() method is the first way to build a CSV file with web scraping. This is a simple method for exporting a DataFrame to a CSV file. However, you must first have your data in a DataFrame before you can export it.