lorey / mlscraper

🤖 Scrape data from HTML websites automatically by just providing examples
https://pypi.org/project/mlscraper/
1.31k stars 89 forks source link

how to save the model ? #26

Closed Tlntin closed 2 years ago

Tlntin commented 2 years ago

I want to save model, so i can use it for next time. I can't found how to do it in example

Tlntin commented 2 years ago

i try to use pickle to save and load scrapper, it work well.

lorey commented 2 years ago

Hi @Tlntin, thanks for getting in touch and even posting the answer you found. Would also be my solution of choice for now. Time for me to create some kind of documentation, I guess...

entrptaher commented 1 year ago

Sample code for future reference,

# train the model
scraper = train_scraper(training_set)

# save the file for future use
file = open('model.pickle', 'wb')
pickle.dump(scraper, file)
file.close()

# load it later
file = open('model.pickle', 'rb')
scraper = pickle.load(file)
file.close()