【发布时间】:2020-06-30 23:44:25
【问题描述】:
我目前正在尝试导航到另一个网页,并使用我抓取的超链接获取其 HTML。 (我需要存储在上面的信息)。
我目前无法让 PHP curl 函数使用我生成的链接获取 HTML 代码。
我试图用来构建/获取 HTML 代码的代码部分是:
foreach($rows as $row)
{
//creating the link itself. https://pr.mo.gov/ is the website itself, the attribute that is returend is the direction location.
// /pharmacy-licensee-search-detail.asp?passkey=1285356, us an example of what I get from getArrtibute('href')
$holder = "https://pr.mo.gov/".$row->getAttribute('href');
// $holder = https://pr.mo.gov/pharmacy-licensee-search-detail.asp?passkey=1285356 as per the example used in the comments above.
echo $holder;
echo "<br>";
//trying to use curl to get the website html
$c = curl_init("$holder");
$html2 = curl_exec($c);
//Trying to print out what has been recived
echo var_dump($html2);
//IT's printing out bool(false)
curl_close($c);
}
这部分之前的代码工作正常——因为它从原始网页中获取了 HTML。如果需要,我会发布。
【问题讨论】:
-
有什么问题?
标签: php parsing curl web-scraping screen-scraping