Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/243.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 检索网站上的电子邮件地址_Php - Fatal编程技术网

Php 检索网站上的电子邮件地址

Php 检索网站上的电子邮件地址,php,Php,我是Android应用程序的发布者 我的网站需要自动检索Android应用程序数据,但Google Play不支持iTunes Store这样的API系统。因此,我需要制作一个PHP命令来帮助检索Android数据。我需要获得标题、应用程序图像、说明和电子邮件地址 首先,当我知道Google Play URL地址时,我正试图获取电子邮件地址。这是我举的一个例子。这是华尔街日报的应用程序 华尔街日报Android应用程序URL- 结果应该是“mobilereader@wsj.com“,但它失败了。

我是Android应用程序的发布者

我的网站需要自动检索Android应用程序数据,但Google Play不支持iTunes Store这样的API系统。因此,我需要制作一个PHP命令来帮助检索Android数据。我需要获得标题、应用程序图像、说明和电子邮件地址

首先,当我知道Google Play URL地址时,我正试图获取电子邮件地址。这是我举的一个例子。这是华尔街日报的应用程序

华尔街日报Android应用程序URL-


结果应该是“mobilereader@wsj.com“,但它失败了。你能看到问题吗?谢谢。

使用正则表达式匹配电子邮件地址。此外,您在过滤器名称中有一个输入错误

试试这个:

$Google_Play_URL = 'https://play.google.com/store/apps/details?id=wsj.reader_sp';
$string = file_get_contents($Google_Play_URL);

preg_match('/<a href="mailto\:(.*)" rel="nofollow">Email Developer<\/a>/s', $string, $matches);
if (count($matches) > 0 && filter_var($matches[1], FILTER_VALIDATE_MAIL))
{
   echo $matches[1];
}
$Google\u Play\u URL='https://play.google.com/store/apps/details?id=wsj.reader_sp';
$string=file\u get\u contents($Google\u Play\u URL);
preg_match('/Email Developer/s',$string,$matches);
如果(计数($matches)>0&&filter\u var($matches[1],filter\u VALIDATE\u MAIL))
{
echo$匹配[1];
}

使用正则表达式匹配电子邮件地址。此外,您在过滤器名称中有一个输入错误

试试这个:

$Google_Play_URL = 'https://play.google.com/store/apps/details?id=wsj.reader_sp';
$string = file_get_contents($Google_Play_URL);

preg_match('/<a href="mailto\:(.*)" rel="nofollow">Email Developer<\/a>/s', $string, $matches);
if (count($matches) > 0 && filter_var($matches[1], FILTER_VALIDATE_MAIL))
{
   echo $matches[1];
}
$Google\u Play\u URL='https://play.google.com/store/apps/details?id=wsj.reader_sp';
$string=file\u get\u contents($Google\u Play\u URL);
preg_match('/Email Developer/s',$string,$matches);
如果(计数($matches)>0&&filter\u var($matches[1],filter\u VALIDATE\u MAIL))
{
echo$匹配[1];
}

您可以使用PHP这样做:


您提供的url的输出示例为:
mobilereader@wsj.com

您可以使用PHP这样做:


您提供的url的输出示例为:
mobilereader@wsj.com

尝试
打印变量(例如
$attrs
)上的r
var\u dump
,看看是否得到了预期效果。“FILTER\u VALIDATE\u MAIL”应该是“FILTER\u VALIDATE\u EMAIL”,url返回一个html页面,您正在将其填充到simplexml中。这意味着您正在尝试检索xml根节点的属性,该节点不包含电子邮件地址。请尝试对变量(例如
$attrs
)执行
print\r
var\u dump
)并查看是否得到了预期的结果。“FILTER\u VALIDATE\u MAIL”应为“FILTER\u VALIDATE\u email”,该url返回html页面,您正在将其填充到simplexml中。这意味着您正在尝试检索xml根节点的属性,该节点不包含电子邮件地址。我将检查HREF是否包含“mailto:”而不是检查nodeValue,因为如果Google更改链接文本,它将不太容易中断,因为Google喜欢更改其布局=o) Steven Farley这一个有效,但它会出错。遇到PHP错误严重性:警告消息:DOMDocument::loadHTML():HTMLPARSENTITYREF:应为“;”在实体中,第34行文件名:admin/db_.php行号:117@Jake只有当HTML具有类似
的实体并且缺少
时,才会发生这种情况在末尾。通过更改此
$dom->loadHTML($string),可以使用
@
抑制警告
@$dom->loadHTML($string)
和警告将被抑制。我将检查HREF是否包含“mailto:”而不是检查nodeValue,因为如果Google更改链接文本,它将不太容易中断,因为Google喜欢更改它们的布局=o) Steven Farley这一个有效,但它会出错。遇到PHP错误严重性:警告消息:DOMDocument::loadHTML():HTMLPARSENTITYREF:应为“;”在实体中,第34行文件名:admin/db_.php行号:117@Jake只有当HTML具有类似
的实体并且缺少
时,才会发生这种情况在末尾。通过更改此
$dom->loadHTML($string),可以使用
@
抑制警告
@$dom->loadHTML($string)和警告将被抑制。
$Google_Play_URL = 'https://play.google.com/store/apps/details?id=wsj.reader_sp';
$string = file_get_contents($Google_Play_URL);

preg_match('/<a href="mailto\:(.*)" rel="nofollow">Email Developer<\/a>/s', $string, $matches);
if (count($matches) > 0 && filter_var($matches[1], FILTER_VALIDATE_MAIL))
{
   echo $matches[1];
}
$Google_Play_URL = 'https://play.google.com/store/apps/details?id=wsj.reader_sp';
$string = file_get_contents($Google_Play_URL);

$dom = new DOMDocument();
$dom->loadHTML($string);
$anchors = $dom->getElementsByTagName('a');

foreach ($anchors as $anchor) {
    if ($anchor->nodeValue === 'Email Developer') {
        $email = str_replace('mailto:', '', $anchor->getAttribute('href'));

        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
            echo $email;
        }
    }
}