How do I save the data from a web site so I can parse it using curl?
Here is what I have so far:
$url="www.test.com";
$post_data = array();
$post_data['var1'] = "val1";
$post_data['var2'] = "val2";
$o="";
foreach($post_data as $k=>$v)
{
$o.= "$k=".utf8_encode($v)."&";
}
$post_data=substr($o,0,-1);
$ch= curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
curl_close($ch);
$parttern="/<TABLE>(.*)<\/TABLE>/";
@preg_match($pattern, ????????, $matches);
print_r($matches[1]);
What would I use for the preg_match? 1 3612
On Mar 22, 1:22 pm, "Aaron" <A...@flasemi.comwrote:
How do I save the data from a web site so I can parse it using curl?
Here is what I have so far:
$url="www.test.com";
$post_data = array();
$post_data['var1'] = "val1";
$post_data['var2'] = "val2";
$o="";
foreach($post_data as $k=>$v)
{
$o.= "$k=".utf8_encode($v)."&";
}
$post_data=substr($o,0,-1);
$ch= curl_init();
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_HEADER,0);
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
curl_close($ch);
$parttern="/<TABLE>(.*)<\/TABLE>/";
@preg_match($pattern, ????????, $matches);
print_r($matches[1]);
What would I use for the preg_match?
You need to:
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
Then, curl_exec($ch) will return the output (and, in your code above,
put it in $result). This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Phil Powell |
last post by:
I am having trouble retrieving URLs using curl for PHP whereby the URL
requires a cookie to produce proper data. I wrote a wrapper class
called Timer that will time the execution/download of a...
|
by: jimb |
last post by:
I need some advice on how to securely transfer data between two servers.
Here is the situation. We have two sql servers that hold student data.
I have full access to my sql server, but only write...
|
by: aka_eu |
last post by:
Hi,
recently I got a project to get info from different websites and to put
the info into a DB.
Now, I was wondering what is the best technique to implement something
like that.
How I should...
|
by: admin |
last post by:
Hi,
I have a mysql box that has a private network ip. The old developer was
running our web server on this machine but the company since retired
the box and it is in a closet, still running, but...
|
by: Paul |
last post by:
I need to get, parse and display RSS feeds while having the ini setting,
allow_url_fopen = Off.
I used to use (in version 4.1) domxml_open_mem() but it's not longer
available in this verison for...
| |
by: devranger |
last post by:
I am using the below CURL Function and can not figure out why it is not
retruning the results from the post. Can anyone take a look and tell
me what I may be doing wrong? I am just not seeing...
|
by: Aaron |
last post by:
How do I save the data from a web site so I can parse it using curl?
Here is what I have so far:
$url="www.test.com";
$post_data = array();
$post_data = "val1";
$post_data = "val2";
$o="";
|
by: Steffen Mutter |
last post by:
Hi there!
I just want to get this http thing into a dynamic scipt using cURL which -
as you might have guessed - I never used before and documentation I found
so far is quite unuseful for me......
|
by: GazK |
last post by:
I have been using an xml parsing script to parse a number of rss feeds
and return relevant results to a database. The script has worked well
for a couple of years, despite having very crude...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |