Methods of populating a database with content automatically?
-
18-04-2021 - |
سؤال
I want to populate a mysql database with basic 'holiday resort' content e.g. name of the resort, description, country. What methods can i use to populate it?
المحلول
First, find the Web sites of one or more holiday companies who offer the destinations you're interested in. You're going to scrape these.
You don't say what language you're using for the implementation, but here is how you might do it in Perl:
- Write a scraper using
LWP::UserAgent
andHTML::TreeBuilder
to explore the site and extract the destination information. - Use
DBI
with theDBD::MySQL
driver to insert the data into your database.
نصائح أخرى
Where is the content? You can use LOAD DATA INFILE
syntax, or import from a CSV file, or write a script in Java or C++ or C# to parse the file(s) holding the data and populate the database via INSERT
statements. You could hire and intern and make him/her type it all up. If you don't have it in a file, you could write a web-spider to go and get crap from Google and stuff it into the database.
But I can't help you until you tell me where the data is.
Ok, I know I'm late but I created an application to (create and/or) auto-populate tables. Below is a short demonstration but check it out here if you want.