chris-greening / instascrape

Powerful and flexible Instagram scraping library for Python, providing easy-to-use and expressive tools for accessing data programmatically
https://chris-greening.github.io/instascrape/
MIT License
634 stars 110 forks source link

Generate CSV #80

Closed wullish closed 3 years ago

wullish commented 3 years ago

Hi Chris,

How can I generate the same type of CSV file that you provided? I mean with all informations organized.

Best.

chris-greening commented 3 years ago

Hello! I combined instascrape with a pandas.DataFrame so that I could leverage the pandas.DataFrame.to_csv method.

import pandas as pd

# Imagine this is a list of scraped instascrape.Post objects 
list_of_post_objects = [...]

post_dicts = [post.to_dict() for post in list_of_post_objects]
df = pd.DataFrame(post_dicts)
df.to_csv("path/to/data.csv")
wullish commented 3 years ago

Nice man! Thank you, work like a charm. I'm now going to try to fit this into scikit-learn following your jupyter notebook file.

chris-greening commented 3 years ago

Love to hear it 😍 I've been busy with some other projects lately but I've got some hot ideas for scikit-learn and an online data dashboard for analyzing instascrape data, keep an eye out for that 😏

Best of luck! I'd love to see what you come up with in the Discusssions