Sunday, January 27, 2013

Crawl Site For Keywords

[sourcecode language="python"]
import re
import urllib2

keywordregex = re.compile('<meta\sname=["\']keywords["\']\scontent=["\'](.*?)["\']\s/>')

try:
response = urllib2.urlopen("http://fun-lanka.site50.net/");
except Exception, e:
print e.args

msg = response.read()
keywordlist = keywordregex.findall(msg)
if len(keywordlist) > 0:
keywordlist = keywordlist[0]
keywordlist = keywordlist.split(", ")
print keywordlist





[/sourcecode]

No comments:

Post a Comment

How to enable CORS in Laravel 5

https://www.youtube.com/watch?v=PozYTvmgcVE 1. Add middleware php artisan make:middleware Cors return $next($request) ->header('Acces...