Algorithm for Friendship, Affair, and Love

IIT Patna: A Journey Began

Google page ranking algorithm

Crawling a website

Performance measure of a website

Performance Measure of a Website (cont'd...)

Code for fetching data from Alexa

# import requests to fetch source code of given website.
from bs4 import BeautifulSoup
def sitevalue(site):
# initialize url
url = "http://www.alexa.com/siteinfo/" + site
# define a variable to get source code of defined "url"
req= requests.get(url)
#parsing of "req" containing source code of "url"
soup = BeautifulSoup(req.content)
# to find title
titel = soup.find("title").text
# to find all value of strong tag
# because so many information are in these strong tags.
#like Global Rank, Country rank, Bounce Rate, Daily Pageviews per Visitor , Daily Time on Site, Search Visits
g_data = soup.find_all("strong", { "class" : "metrics-data align-vmiddle" })
#to find change in rank
changerank = soup.find("span", { "class" : "align-vmiddle change-wrapper change-down color-gen2 change-r2"}).text
#to find "Total Sites Linking In" .
Linking = soup.find("span",{"class": "font-4 box1-r"}).text
keywords = soup.find_all("td")
# for key in keywords:
# soup.find_all("title=""")
# print key.text
return g_data,changerank, Linking,keywords,titel
site = "http://www.iitp.ac.in/"
g_data, changerank, Linking,keywords,titel = sitevalue(site)
for data in g_data:
a.append( data.text) )
print titel )
print "Global Rank=" +a[0] )
print "Rank changed since 3 months="+changerank )
print "Country rank="+a[1] )
print "Bounce Rate="+a[2] )
print "Daily Pageviews per Visitor="+a[3] )
print "Daily Time on Site="+a[4] )
print "Search Visits="+a[5] )
print "Total Sites Linking In="+Linking


< Prev.Page   1   2   3   4   5   6   Next page>