Skip to content

Instantly share code, notes, and snippets.

@krishnakummar
Created November 12, 2013 11:16
Show Gist options
  • Save krishnakummar/7429310 to your computer and use it in GitHub Desktop.
Save krishnakummar/7429310 to your computer and use it in GitHub Desktop.
Create a html page to display all the profile images from ssmatri.com. This is for easy viewing. Its boring to click on each and every profile to view their details.
import requests
import BeautifulSoup
fo = open("ossmat.html", "wb")
session = requests.session()
for page in range(1,10):
req = session.get('http://ssmatri.net/setup/ProfileListview.asp?type=GI&sh=1&thisPage='+ str(page))
doc = BeautifulSoup.BeautifulSoup(req.content)
all_td = doc.findAll('tr')
#for x in range(10,20):
starting_row = all_td[11]
ending_row = all_td[61]
all_href = starting_row.findAll('a')
for x in range(11,111):
if(x%2 != 0):
data = all_td[x]
all_links = data.findAll('a')
if(len(all_links) == 3):
href_link = 'http://ssmatri.net/setup/'+all_links[1]['href']
profile_link = session.get(href_link)
profile_data = BeautifulSoup.BeautifulSoup(profile_link.content)
profile_data = profile_data.findAll('table')
name = "<BR>" + profile_data[1].find('font',{'color':'#009933'}).string + "<BR>"
fo.write("<a target='_blank' href='"+ href_link + "'>" + name + "</a>")
images = profile_data[1].findAll('img')
for image in images:
if(image['src'] != 'images/bot.gif'):
image_url = 'http://ssmatri.net/'+ image['src'].replace('../','')
fo.write("<img src=" + image_url + " />")
fo.write("<hr>")
fo.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment