5 回答
一个快速而肮脏的 Cygwin Bash 脚本可以完成这项工作:
#!/bin/bash
for file in $(find $WWWROOT -iname \*.aspx); do
echo -en $file '\t'
cat $file | tr '\n' ' ' | sed -i 's/.*<title>\([^<]*\)<\/title>.*/\1/'
done
说明:这会找到根目录 $WWWROOT 下的每个 .aspx 文件,将所有换行符替换为空格,以便<title>
and之间没有换行符</title>
,然后抓取这些标记之间的文本。
我认为类似于Adam Rosenfield 建议的脚本是您想要的,但如果您想要实际的 URL,请尝试使用wget
. 使用一些适当的选项,它会打印出您网站上所有页面的列表(加上下载它们,也许您可以使用 取消--spider
)。该wget
程序可通过正常的 Cygwin 安装程序获得。
我会使用上面详述的 wget 。确保您的网站上没有任何蜘蛛陷阱。
你应该考虑使用scrapy shell
查看
http://doc.scrapy.org/intro/tutorial.html
在控制台中放这样的东西:
hxs.x('/html/head/title/text()').extract()
如果你想要所有的标题,你应该做一个蜘蛛......这真的很容易。
还可以考虑迁移到 linux :P
Ok, I'm not familiar with Windows, but to get you in the right direction: use a XSLT transformation with
<xsl:value-of select="/head/title" /> in there to get the title back or if you can, use the XPath '/head/title' to get the title back.