php - CURL 中使用的列表中的多个 URL
问题描述
我创建了这个脚本:
<?php
</head>
<form class="form-horizontal" method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<fieldset>
<legend>Linki</legend>
<div class="form-group">
<label class="col-md-4 control-label" for="textarea">Linki</label>
<div class="col-md-4">
<textarea class="form-control" id="textarea" name="name">kazdy link w osobnej linijce </textarea>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label" for="wyslij"></label>
<div class="col-md-4">
<button id="wyslij" name="wyslij" class="btn btn-default">Button</button>
</div>
</div>
</fieldset>
</form>
<table>
<?
for ($i = 0; $i <= $count; $i++) {
echo "<tr><td>".$lista[$i]."</td></tr>";
}
?>
</table>
</html>
它没有像我预期的那样工作。
当我在表单中输入 url 时,它会用爆炸来切割它,并且每个 url 都设置为新的列表元素。
例如网址:
google.com
yahoo.com
ebay.com
创建
lista[0] -> google.com
lista[1] -> yahoo.com
lista[2] -> ebay.com
现在我想使用列表中的每一个 url$html = "file_get_contents_curl($lista[$i]);"
来抓取og:image
但它不起作用。当我在表单中只使用一个 url 时,它会创建结果 url 以og:image
从侦听的 url。当表单中有多个 url 时,结果它只显示表单中的 url。
例如它应该如何工作:
网址形式:
https://www.ebay.com/itm/NEW-HP-Stream-14-Laptop-Celeron-N3060-4GB-RAM-32GB-32-GB-eMMC-Windows-10/292593246536?_trkparms=5373%3A5000006400%7C5374%3ATech%7C5079%3A5000006400
返回:
https://i.ebayimg.com/images/i/292593246536-0-1/s-l1000.jpg
网址形式:
https://www.ebay.com/itm/NEW-HP-Stream-14-Laptop-Celeron-N3060-4GB-RAM-32GB-32-GB-eMMC-Windows-10/292593246536?_trkparms=5373%3A5000006400%7C5374%3ATech%7C5079%3A5000006400
https://www.ebay.com/itm/NEW-HP-Stream-14-Laptop-Celeron-N3060-4GB-RAM-32GB-32-GB-eMMC-Windows-10/292593246536?_trkparms=5373%3A5000006400%7C5374%3ATech%7C5079%3A5000006400
应该返回:
https://i.ebayimg.com/images/i/292593246536-0-1/s-l1000.jpg
https://i.ebayimg.com/images/i/292593246536-0-1/s-l1000.jpg
但相反,它返回:
https://www.ebay.com/itm/NEW-HP-Stream-14-Laptop-Celeron-N3060-4GB-RAM-32GB-32-GB-eMMC-Windows-10/292593246536?_trkparms=5373%3A5000006400%7C5374%3ATech%7C5079%3A5000006400
https://www.ebay.com/itm/NEW-HP-Stream-14-Laptop-Celeron-N3060-4GB-RAM-32GB-32-GB-eMMC-Windows-10/292593246536?_trkparms=5373%3A5000006400%7C5374%3ATech%7C5079%3A5000006400
如何改变它。我是 php 的新手,并在几个小时内从 Internet 上的其他脚本中创建了此代码。
解决方案
for ($i=0; $i<=$count; $i++)
应该for ($i=0; $i<$count; $i++)
,curl_close($ch);
应该叫进来file_get_contents_curl
。您是否确认og:image
这三个网站中的每一个都存在?
推荐阅读
- ios - 为什么SVProgressHUD会抛出eorrr?
- python - 如何根据Python中的字符数拆分文本文件
- reactjs - 如何测试是否调用了useState或单击了按钮?
- flutter - 如何将创建的 pdf 共享到 whatsapp 到特定号码?尝试了所有不起作用的软件包..我只能发送文本
- python - Python实时边缘检测 - 从每一帧中获取白色像素的数量
- javascript - 无法设置角度异步验证器
- nlp - len(tokenizer) 和 tokenizer.vocab_size 有什么区别
- r - 检查数据框行中的特定重复次数
- masstransit - 重新启动 MassTransit Saga
- aws-lambda - 具有获取模型和 lambda 函数的 AWS AppSync GraphQL 管道解析器