0

I'm starting in Curl / php and I'm really enjoying what it can do. Although, I'm blocked for several days on something and I really need help.

There are some peculiar datas I need to grab and treat with another script thanks to a txt file.

The datas are proxies posted on my forum by a member which agreed to be published in a external website related to the forum.

The proxies are under this form

107.2.178.129:47535<br/>173.174.251.89:18785<br/>173.48.224.237:1807<br/>and so on ... 

I would need them to be placed in a text file with one proxy per line.

Here is what I have so far

<?php


$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, 'http://www.external-site.com/Members/Login.php');

curl_setopt ($ch, CURLOPT_POST, 1);

curl_setopt ($ch, CURLOPT_POSTFIELDS,
'fieldname1=fieldvalue1&fieldname2=fieldvalue2');

curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');

curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);

$store = curl_exec ($ch);

curl_setopt($ch, CURLOPT_URL,
'http://www.external-site.com/index.cgi?action=display&thread=26');

$content = curl_exec ($ch);

curl_close ($ch); 

?>

After that I'm stuck.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

1 Answers1

3

So you've gotten the forum post text? Assuming $content is valid:

file_put_contents('proxies.txt', implode('\n', explode('<br/>', $content)));

Use \n on Linux, or \r\n on Windows.

Eric
  • 3,773
  • 3
  • 29
  • 29