【发布时间】:2019-10-24 00:26:11
【问题描述】:
我想从 ask 中提取 url 信息。 com
这是标签
<p class="PartialSearchResults-item-url">maps.google.com </p>
这是代码,我试过了,但它正在提取垃圾信息。
$p = HTML::TokeParser->new(\$rrs);
while ($p->get_tag("p")) {
my @link = $p->get_trimmed_text("/p");
foreach(@link) { print "$_\n"; }
open(OUT, ">>askurls.txt"); print OUT "@link\n"; close(OUT);
}
我只想要域网址,例如 maps.google.com
但它正在提取 Source 、 Images 和各种其他 p 类信息垃圾,用不相关的信息填充 askurls.txt
添加:
askurls.txt filled with this information:
Videos
Change Settings
OK
Sites Google
Sites Google.com Br
Google
Cookie Policy
assistant.google.com
Meet your Google Assistant. Ask it questions. Tell it to do things. It's your own personal Google, always ready to help whenever you need it.
www.google.com/drive
Safely store and share your photos, videos, files and more in the cloud. Your first 15 GB of storage are free with a Google account.
translate.google.com
Google's free service instantly translates words, phrases, and web pages between English and over 100 other languages.
duo.google.com
【问题讨论】:
-
源文档是什么样的?
-
检查,我添加了 askurl.txt 信息