【发布时间】:2018-03-03 10:40:46
【问题描述】:
我有一个任务。表on this page contains links。在每个链接for exampple first 中,存在一个带有电子邮件的字段。我必须复制所有这些电子邮件。
我使用 phpQuery 编写脚本。
<?php
header('Content-type: text/html; charset=utf8');
require 'phpQuery-onefile.php';
function parseMail($url){
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
foreach ($doc->find('#table_top > tbody > tr')as $tempmail{
$tempmail = pq($tempmail)
$mail = $tempmail->find("contains('@')");
}
}
function print_arr($arr){
echo '<pre>' . print_r($arr, true) . '</pre>';
}
$url = 'http://www.topscolibucuresti.ro/bucuresti';
$file = file_get_contents($url);
$doc = phpQuery::newDocument($file);
foreach($doc->find('#table_top > tbody > tr')as $article){
$article = pq($article);
$link = $article->find('a')->attr('href');
parseMail($link);
print_arr($mail);
}
脚本显示错误,但我不明白为什么.. 我该怎么办?
【问题讨论】:
-
嘿伙计,我看到了链接,但在您提供的网站上没有任何电子邮件地址。我错过了什么?
-
嗨。欢迎来到堆栈溢出。您是否先尝试使用另一个较小的网页来解决问题? (即,您是否尝试过单独重现问题?)查看帮助中心,了解如何编写出色的问题 (stackoverflow.com/help/on-topic)
-
@Jonathon,谢谢.. 我会看看。我没有孤立地尝试。你认为它会有结果吗?
-
@Yitzhak 我需要打开每个链接。在这些页面中存在电子邮件。例如第一个链接:topscolibucuresti.ro/scoala/colegiul-national-gheorghe-lazar
-
@engins:你得到了什么错误?