admin管理员组文章数量:1333735
I've started to work on a project regarding WordPress Website, I have some experience with WordPress, but it's not on the level I want it to be in the incoming months.
I'm more of a Python Developer then Wordpress Developer, so my question may be a bit noobie.
The website was organized around scraping and providing those scraped data to end-users. So I started to rebuild the scraped because it had too many bugs, and here my question begins, the last script was written in PHP, and my scraper is being built in Python.
So I am wondering, when script output the data, the user will need to upload it to WordPress, is there any better more automated solutions, where I can store it in some DB, and then just migrate data from that DB to the WordPress DB, but I've looked few things online, but it's mostly some add-ons that do not give any answers.
Has someone did something like this, any advice would be helpful.
I've started to work on a project regarding WordPress Website, I have some experience with WordPress, but it's not on the level I want it to be in the incoming months.
I'm more of a Python Developer then Wordpress Developer, so my question may be a bit noobie.
The website was organized around scraping and providing those scraped data to end-users. So I started to rebuild the scraped because it had too many bugs, and here my question begins, the last script was written in PHP, and my scraper is being built in Python.
So I am wondering, when script output the data, the user will need to upload it to WordPress, is there any better more automated solutions, where I can store it in some DB, and then just migrate data from that DB to the WordPress DB, but I've looked few things online, but it's mostly some add-ons that do not give any answers.
Has someone did something like this, any advice would be helpful.
Share Improve this question asked Jun 20, 2020 at 8:08 StefanStefan 1032 bronze badges1 Answer
Reset to default 1Since you are building the scraping functionality outside of WordPress, you will have to use a way that allows you to add contents to WordPress from the outside as well. I basically see three options:
- Update via the REST API - Using the REST API you can post updates to the WordPress contents. You can do this right from your Python scraper code, posting to the REST API directly, when there is a change in the data. For example, you can create a post or update a post. The REST API is capable of handling
- Read the external database from WordPress - Alternatively, you could write a script that periodically checks the database where the Python scraper stores its data, for new changes. You could for example write a WP-CLI script that runs every x minutes (using a cron). That WP-CLI script in turn reads the external database and uses native WordPress functions like
wp_insert_post()
andwp_update_post()
to save the data to WordPress. - Build functionality to live read external database - Depending on what kind of data you are working with, importing the data might not be suitable. You could also make a page template that reads the external database while it is requested. The data doesn't have to be stored in WordPress in order to be shown in WordPress pages. In this case, you would consider the database to be an external source, like an API, from where you fetch data as you need it.
Implementations like this often get really specific, so these are just pointers of the routes you could go. Depending on the type of data, the volume of the data and the interval in which the data is updated, one of these routes should suit your use case best.
本文标签: databaseTransferringUploading Data from DB to WordPress
版权声明:本文标题:database - TransferringUploading Data from DB to WordPress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742331942a2454868.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论