PHP preg_match_all 与 Curl
我有一个 PHP 脚本,它向 market.android.com/mylibrary 提交curl 请求并检索页面,然后使用正则表达式对其进行解析。在下面的第一个链接中,您可以看到运行时它将输出与底部的每个正则表达式测试相对应的“Something goneErrorSomething goneError”。现在,如果您注释第 74 行并取消注释 75,它将起作用。如果您想查看curl返回的内容,只需在底部添加echo($result);
即可。
请务必在顶部填写您的 Google 信用信息并在您的网络服务器中启用curl --> 示例文件 1
现在,在第二个示例中,我仅从卷曲结果中获取了相关部分,并手动转义了所有内容撇号。我将相同的正则表达式字符串放在底部,它的工作原理与预期完全一致。
有谁能看出问题的原因吗?我尝试过使用 preg_last_error() 但它只是返回 0
。谢谢!
I have a PHP script that submits a curl request to market.android.com/mylibrary and retrieves the page, then parses it using regex. In the first link below you can see that when run it will output "Something went wrongSomething went wrong" corresponding to each of the regex tests at the bottom. Now if you comment line 74 and uncomment 75 it will work. If you would like to see what the curl is returning just add echo($result);
at the bottom.
Be sure to fill in your Google creds at the top and enable curl in your webserver -->
Example file 1
Now in this second example I have taken only the relevant portions from the curl results and manually escaped all the apostrophes. I put the same regex strings at the bottom and it works exactly as expected.
Is anyone able to see what is causing the problem? I have tried using preg_last_error() but it simply returns 0
. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢评论中提供的提示,我得到了这个工作。这是解决方案:
I got this working thanks to the tips provided in the comments. Here is the solution: