Jump to content

cURL Help


killah

Recommended Posts

I am currently stuck on a solution. Let me explain, i have built a script which will take my test site & register the account, after that it then log's the account in.

 

After the account has logged in. I need it to send it to another script.. Ok i got the script working to this part. The script basicly work's like this.

 

Post form data -> register.php -> login.php -> mailbox.php?action=send

 

so far that work's and send's the mail. My problem stand's that the user were sending to, can be anything. This is why i have came here.

 

I need my curl script to send to usersonline.php and get a name inbetween a url link (<a href='viewuser.php?u=xx'>YY</a> xx => id, YY => name), i need to grab YY and put it in an array, so i can use it later on.

 

Is there anyway to grab a name inbetween a html tag using cURL?

 

I have the rest covered by going to usersonline.php and all.

 

Thank's.

Link to comment
https://forums.phpfreaks.com/topic/162242-curl-help/
Share on other sites

Here's an update.

 

curl_setopt($log, CURLOPT_URL, $url.'/usersonline.php');
$mat = str_replace(array('<','>'),array('[',']'), curl_exec($log));
echo $mat;
$mat = preg_replace('~\[a href=\'viewuser.php?u=(.*)\'\](.*)\[/a\]~is','[pid]$2[/pid]', $mat);
preg_match('~\[pid\](.*)\[/pid\]~is', $mat, $matches);
print_r($matches);

 

It displays:

 

[a href=viewuser.php?u=2]Kyle[/a]

 

But it simply won't grab the bit inside ]YY[

 

 

I just noticed your using preg_match when it's supposed to be preg_match_all, but now my array returns:

 

Array ( [0] => Array ( ) [1] => Array ( ) )

Link to comment
https://forums.phpfreaks.com/topic/162242-curl-help/#findComment-856301
Share on other sites

<?php

$curl_return = '<a href=\'viewuser.php?u=something\'>username</a>';

$curl_return = str_replace(array('<', '>'), array('[', ']'), $curl_return);


preg_match('/\[a href=\'viewuser\.php\?u=[a-z]+\'\]([a-z]+)\[\/a\]/i', $curl_return, $matches);
print_r($matches);

Come on..surely you can adapt this.

Link to comment
https://forums.phpfreaks.com/topic/162242-curl-help/#findComment-856304
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.