如何自动验证网络表单?
我在 stackoverflow 上找到了这段代码,代码为 https://stackoverflow.com/users/370876/peter-anselmo
$url = 'http://www.targeturl.com';
$myvars = 'myvar1=' . $myvar1 . '&myvar2=' . $myvar2;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
我想填写两个字段,一行可以,或者需要两行(使用curl) 我怎样才能像“if”一样测试返回的url是否是我想要的,然后重试(就像循环)。 我知道我问
I found this code on stackoverflow, code of https://stackoverflow.com/users/370876/peter-anselmo
$url = 'http://www.targeturl.com';
$myvars = 'myvar1=' . $myvar1 . '&myvar2=' . $myvar2;
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, 1);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars);
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt( $ch, CURLOPT_HEADER, 0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec( $ch );
I want to fill two fields, one line is ok or two are needed (with curl)
and how can I make like an "if" to test if the url returned is what I want or no and re-try again (like a loop).
I know I ask
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不太确定你的问题是什么意思,我有点困惑,但你是在问这样的事情吗?
此循环将继续执行并发出 CURL 请求,直到响应与您正在搜索的某个 URL 匹配...
Not really sure what you mean by your question, I'm sort of confused, but are you asking for something like this?
This loop will continue to execute and make CURL requests until the response matches some URL that you're searching for ...