如何从论坛帖子中获取数据?
我从 Curl / php 开始,我真的很喜欢它的功能。不过,我在某件事上受阻了好几天,我真的需要帮助。
由于 txt 文件,我需要使用另一个脚本来获取和处理一些特殊的数据。
这些数据是由一名成员在我的论坛上发布的代理,该成员同意在与论坛相关的外部网站上发布。
代理处于这种形式下,
107.2.178.129:47535<br/>173.174.251.89:18785<br/>173.48.224.237:1807<br/>and so on ...
我需要将它们放置在文本文件中,每行一个代理。
这是我到目前为止所拥有的
<?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);
?>
,之后我被困住了。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么您已经收到论坛帖子文本了吗?假设
$content
有效:在 Linux 上使用
\n
,在 Windows 上使用\r\n
。So you've gotten the forum post text? Assuming
$content
is valid:Use
\n
on Linux, or\r\n
on Windows.