22 April, 2011

How to change dns address in Windows

 The domain name servers plays a big role in the case of world wide web. It converts the human understandable URLs or host names such as google.com or yahoo.com into machine understandable IP addresses. It is very important to select the best DNS server from a list of available ones since the right selection will reflect in the browsing speeds. Actually when an internet user types some url and hit the enter key, the  role of dns server (usually provided by the correspponding internet service provider for example bsnl or vodafone ) comes into effect. 

The dns server converts the hostname to the corresponding IP address and returns the IP back to the browser.Usually the dns server uses tables to store the hostname and ip, also a domain naming system is also implemented as a distributed system. 

Leave the theories ... lets findout the best dns server that suits you and change the your default dns value to the best one that is more fast and reliable using the following steps...

Before that, the public and free dns address available are 

google public dns
8.8.8.8
8.8.4.4
opendns
208.67.220.220
208.67.222.222

dns advantage

156.154.70.1
156.154.71.1

others
209.244.0.3
209.244.0.4





1. Use the ping command to find the dns server with less average RTT (round trip time).

Take the command prompt and use the average value of round trip time in the ping command to spot the best dns address. Check the figure.

  > ping <dns address here>

  

2. Replace the default dns address with the new one



Take 'Network and Sharing Center' from the control panel. Select the 'Manage Network Connections' from the left side panel. Select the connection and right click to select the 'Properties' from the menu.


Select the TCP/IPv4 under the Networking tab and click the 'properties' button to change its properties. 


Inside the TCP/IPv4 properties click on the 'Use following DNS server' and add the DNS server address there as shown in the image below.

If the connection is already active you may have to restart the connection to make the changes take into effect. 




That's all about the configuration. From my personal experience google's public dns addresses are fast and reliable than the others. Almost a lion's share of time i spend on internet is usually with google related sites such as google search engine, analytics, blogger... The method for changing the dns address in Ubuntu linux is explained in the post linked here
Read rest of entry

27 January, 2011

python urllib library : the basics

               urllib and urllib2 are Python modules for fetching URLs. It offers a very simple interface, in the form of the urlopen function which is capable of fetching URLs. It also offers a  slightly more complex interface for  handling features like basic authentication, cookies, proxies and soon.

urllib2 supports fetching URLs for many URL schemes  such as ftp, http -- for example “ftp” is the URL scheme of “ftp://python.org/“

Fetching URLs : urlopen()
 
Now it is the time to play off the theories. The simplest way to use urllib2 to open urls is as follows:
  import urllib2
  response = urllib2.urlopen(’http://python.org/’)
  html = response.read()
You can use the above method to store the complete contents of a file into a variable without writing it to a local file... 

Sending Data along with url 
                Sometimes you want to send data to a URL (often the URL will refer to a CGI script or other web application). With HTTP, this is often done using  a GET/POST request. This is what your browser does when you submit a HTML form that you filled in on the web. In the common case of HTML forms, the data needs to be encoded in a standard way, and then passed to the Request object as the data argument. In python encoding is done using a function from the urllib library.

  import urllib
  import urllib2
  url = ’http://www.someserver.com/cgi-bin/register.cgi’
  values = {’name’ : ’Michael Foord’,
                             ’location’ : ’Northampton’,
                             ’language’ : ’Python’ }
  data = urllib.urlencode(values)
  req = urllib2.Request(url, data)
  response = urllib2.urlopen(req)
  the_page = response.read()

This can be done manually as follows :

  import urllib2
  import urllib
  data = {}
  data[’name’] = ’Somebody Here’
  data[’location’] = ’Northampton’
  data[’language’] = ’Python’
  url_values = urllib.urlencode(data)
  print url_values
  name=Somebody+Here&language=Python&location=Northampton
  url = ’http://www.example.com/example.cgi’
  full_url = url + ’?’ + url_values
  data = urllib2.open(full_url)

Fetching files : urlretrieve()

We can use urllib's urlretrieve function to download a file over internet and save it in a new name. We can download text / image / video files using this function if the source file is available as a url.

 import urllib
 url=https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjAEaU33AHSR1u5v4ulLwW6ll9sIy5j7GbCoFQkC6bXbnl8EQrf8NPjlVbeC_6OShG00vi0R6sT_GTXkueNsXUnZEkq2IcLwyRmIQke2JzeKrh7lWd9YR5Sjob3a9AZsfuh4ENpmt1MT8Wy/s104/ubuntu.png 
 urllib.urlretrieve(url, new_image.png) 
Hope you have enjoyed the basics of the urllib library of python...

Read rest of entry
 

Terminal Diary | techblog Copyright © 2009 Gadget Blog is Designed by jintu jacob Powered by Blogger