Saturday 22 August 2015

Link Miner

Link miner bot

This bot will extract all the link from a fetched web content and displays it on the screen. Not only the word having the link, this bot will extract the URL to where it points. Here is the code..

import mechanize
def linkminer():                      
    browser = mechanize.Browser(factory=mechanize.RobustFactory())
    browser.set_handle_robots(False)
    browser.open("http://www.minerbots.blogspot.in/")  #you can give your url
    html = browser.response().readlines()
    for link in browser.links():
      print link.text, link.url
      print 
 

  Output will look like this..





No comments:

Post a Comment