Fetch bookmarks from Browser using Python

Tags: Python, json, bookmark, browser, firefox, tags

bookmark_json.py gist

 

So, after making a python script for fetching bookmarks from the exported HTML files, I was wondering how to make it work automatically so that I don’t need to give the HTML file every time. I started looking in firefox directory for some bookmark files which I could use. I found out that firefox keeps bookmark backups and they are encoded in json. I learned few things about json and started to write the script.
Importing Modules

import json
import os

Locate the directory in which the browser stores the bookmarks backup. Continue reading

Fetch bookmarks from browser(html version) using Python

Tags : Python, BeautifulSoup, bookmark, browser, html

bookmark.py gist

Priyans Murarka was having troubles managing his bookmarks. He wanted to keep all the bookmarks from all the browsers from all the OSes in one place. So, I suggested him to use rowz . It’s a really good website to keep your bookmarks at one place and also you can view others’ bookmarks also. Recently, they added a new feature, using which one could import the bookmarks from the browser. What they do is they ask you to export your bookmarks in an HTML file and upload it on the site. So, I see an HTML file, and all I can think of is BeautifulSoup. So, I open the HTML file. And.. OK! it’s damn easy!
Importing Modules

from BeautifulSoup import BeautifulSoup
import time

Continue reading

Monitor your Browsing/Downloading data via Python

Download-Monitor

So here’s a small script which will monitor the amount of your browsing/downloading data.
I have used pypcap and dpkt library. dpkt is a library which provides packets creation/ parsing capabilities with an object oriented interface. The project is hosted at http://code.google.com/p/dpkt/ .

#!/usr/bin/python2.7
import pcap, dpkt, socket

pc = pcap.pcap()
ports = (80, 8080, 443, 888) # for HTPP and HTPPS

pc is now my pcap.pcap object. pcap objects are their own iterator returning the timestamp and
the packet as a 2-tuple.

def process():
  mem = sport = dport = 0
  try:
    for ts, pkt in pc:
      eth = dpkt.ethernet.Ethernet(pkt)
      ip = eth.data

Continue reading