开发者

How can I pull data from other websites and get it stored in my local database

开发者 https://www.devze.com 2023-01-03 01:49 出处:网络
I pull a data from o开发者_StackOverflow社区ther website by using curl but how to store in my local database.

I pull a data from o开发者_StackOverflow社区ther website by using curl but how to store in my local database.

$url = 'http://sample.com/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;

I just want post some categories and sample of data.


right.

well, i asume you're using mysql as database. if you have allready set up your database including a table owning a blob or text formatted field you can easily store the data there by sending a query like:

"INSERT INTO mytable SET curlData='".$data."';"

with PHP you can connect to your DB via mysql_connect() after selecting the desired database with mysql_select_db() you can start sending queries to the db.

use the mysql_connect() php-native-call to do so.

I hope i was helpful now ;-)

by the way, check out the php-mysql manual for further information.

0

精彩评论

暂无评论...
验证码 换一张
取 消