Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Saturday, May 28, 2011

Fetch Web Pages in Python using urllib2

urllib2 is an extensible library for opening URLs. Mostly, we will use fetch data from URLs via HTTP. We can use it to access normal Website, HTTP Authentication, Web Proxy, and etc. urllib2 is included in python standard library.

Example:

import urllib2
# Normal usage
f = urllib2.urlopen('http://wwww.google.com')
print f.read()

# Use under Proxy
auth_handler = urllib2.ProxyBasicAuthHandler(urllib2.HTTPPasswordMgrWithDefaultRealm())
auth_handler.add_password(realm=None,uri='proxy-name',user='username',passwd='password')
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
f = urllib2.urlopen('http://wwww.bing.com')
print f.read()

In the example, It use GET to fetch data. If you want to change it to POST, you have to put data attribute in the method.

The basic usage is "urllib2.urlopen(url[, data][, timeout])".

More details at: http://docs.python.org/library/urllib2.html

Sunday, May 22, 2011

So You Think You Can Dance Online

So You Think You Can Dance is an American Dance reality show. It is broadcast on the Fox Channel. It's marvelous. I began to watch it since March via AXN Channel during vacation. Each competitor has a high standard in dancing, so it make me feel excited when I'm watching it.

Watch at: http://www.sidereel.com/So_You_Think_You_Can_Dance

Or you may download it directly using KeepVid, or Keep-Tube without any limitation from MegaUploadVideo. Enjoy watching ><!

Wednesday, May 18, 2011

The differences between get and post method in HTTP

Sometimes, I confuse which method should be used in HTTP. Now, I have found the answer from http://wiki.answers.com.

The answer is here:
GET Method:
  1. All the name value pairs are submitted as a query string in URL.
  2. It's not secured as it is visible in plain text format in the Lacation bar of the web browser.
  3. As the data transfers through address bar (URL) there are some restrictions in using space, some characters like ampersand (&) etc in the GET method of posting data. We have to take special care for encoding data if such special characters are present.
  4. Length of the string is restricted.
  5. If method is not mentioned in the Form tag, this is the default method used.
  6. If get method is used and if the page is refreshed it would not prompt before the request is submitted again.
  7. One can store the name value pairs as bookmark and directly be used while sharing with others - example search results.
  8. Data is always submitted in the form of text
  9. If the response of the page is always same for the posted query then use GET example database searches
POST Method:
  1. All the name value pairs are submitted in the Message Body of the request.
  2. Length of the string (amount of data submitted) is not restricted.
  3. Post Method is secured because Name-Value pairs cannot be seen in location bar of the web browser.
  4. If post method is used and if the page is refreshed it would prompt before the request is resubmitted.
  5. If the service associated with the processing of a form has side effects (for example, modification of a database or subscription to a service), the method should be POST.
  6. Data is submitted in the form as specified in enctype attribute of form tag and thus files can be used in FileUpload input box.

Read more: http://wiki.answers.com/Q/What_is_the_difference_between_get_and_post_method_in_HTTP

Thursday, May 5, 2011

As follow VS As following

http://www.andrewbiggs.com/smf/index.php?topic=76.0
These two words usually make me feel confused how to use them all the time - -*.

Free ASP.NET MVC “NerdDinner” Tutorial

 Here, you will know a lot of basic things for ASP.NET MVC framework as following topics:

Interesting Silverlight blog posts

7 Simple Steps to Connect SQL Server using WCF from SilverLight
WCF Basics - Data Contracts
Silverlight: How to Send Message to Desktop Application
Silverlight: How to Receive Messages from Desktop Application
RIATasks: A Simple Silverlight CRUD Example (using View Model)
A Sample Silverlight 4 Application Using MEF, MVVM, and WCF RIA Services
Silverlight Elevated Permissions
Full-Screen Support