Download presentation
Presentation is loading. Please wait.
Published byKaren Henderson Modified over 9 years ago
1
Python Basic
2
Download python Go to www.python.org and download Python 2.7.8www.python.org
3
Follow steps below 1. Search “phthon download” in google. 2. Click https://www.python.org/downloads/.https://www.python.org/downloads/ 3. Download Python 2.7.8. 4. Click “run”. 5. Click “next” in below screen.
4
6. Click “next “. 7. Click “next”, and click “finish”.
5
Ex1: Reading specific value from web
6
8. Open Python
7
9. Go to 10. Go to
8
11.Choose ‘File’ and ‘New File’
9
12. Edit code here
10
13. Edit below code. import urllib import re htmlfile = 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']
11
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!
12
15. After coding is over run program as below: choose ‘run’ and click ‘Run Module’
13
Code & ouput
14
Code & output
15
Ex2: crawling web page(s) with key value
16
Type below for crawling google
17
Full code # -*- coding:utf-8 -*- import urllib2 url='http://www.google.co.kr' html=urllib2.urlopen(url).read() print(html)
18
output
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.