我编写了简单的 Python 脚本,该脚本连接到特定网站并获取那里的所有链接。
import urllib2
import re
request = urllib2.urlopen('http://www.securitytube.net/')
content = request.read()
match = re.findall(r'<a href=".\w+.\d+">.+</a>', content)
if match:
for i in match:
print i + "\n"
else:
print 'Not Found!'
结果:
<a href="/video/3878"><img class="corner iradius20 ishadow33" width="100" heigh
t="75" src="http://videothumbs.securitytube.net.s3.amazonaws.com/3878.jpg" alt=
"avatar" /></a>
<a href="/video/3878">NodeZero Linux Review</a>
<a href="/video/3877"><img class="corner iradius20 ishadow33" width="100" heigh
t="75" src="http://videothumbs.securitytube.net.s3.amazonaws.com/3877.jpg" alt=
"avatar" /></a>
<a href="/video/3877">Post Attack Uploading Shell in Real Time</a>
<a href="/video/3867"><img class="corner iradius20 ishadow33" width="100" heigh
t="75" src="http://videothumbs.securitytube.net.s3.amazonaws.com/3867.jpg" alt=
"avatar" /></a>
<a href="/video/3867">Using SQLMAP in Real Time (SQLinjection WEB)</a>
<a href="/video/3866"><img class="corner iradius20 ishadow33" width="100" heigh
t="75" src="http://videothumbs.securitytube.net.s3.amazonaws.com/3866.jpg" alt=
"avatar" /></a>
....
...
...
我正在尝试使用可理解的标题获取这些链接,例如<a href="/video/3867">Using SQLMAP in Real Time (SQLinjection WEB)</a>
.
我的模式是:<a href=".\w+.\d+">.+</a>