python basic. download python go to and download python 2.7.8

of 18/18
Python Basic

Post on 05-Jan-2016

262 views

Category:

Documents

13 download

Embed Size (px)

TRANSCRIPT

Python Basic

Python BasicDownload python

Go to www.python.org and download Python 2.7.8Follow steps below1. Search phthon download in google.2. Click https://www.python.org/downloads/.3. Download Python 2.7.8.4. Click run.5. Click next in below screen.

6. Click next .7. Click next , and click finish.Ex1: Reading specific value from web8. Open Python

9 . Go to

10 . Go to

11.Choose File and New File

12. Edit code here

13. Edit below code.

import urllibimport rehtmlfile = urllib.urlopen("http://finance.yahoo.com/q?s=AAPL")htmltext = htmlfile.read()regex = '(.+?)'pattern = re.compile(regex)price = re.findall(pattern, htmltext)print price

After you hit enter you can see the output below.['116.47']

14. Go to and link finance.yahoo.com in chrome -> Block the value to be read and right click on the block-> Click component search -> Then, you can see the screen below. Copy the blocked code below!

15. After coding is overrun program as below: choose run and click Run Module

Code & ouput

Code & output

Ex2: crawling web page(s) with key valueType below for crawlinggoogle

Full code# -*- coding:utf-8 -*-import urllib2url='http://www.google.co.kr'html=urllib2.urlopen(url).read()print(html)

output