government data integration
Download
Skip this Video
Download Presentation
Government Data Integration

Loading in 2 Seconds...

play fullscreen
1 / 43

Government Data Integration - PowerPoint PPT Presentation


  • 77 Views
  • Uploaded on

Government Data Integration. หลักสูตรเบื้องต้น REST. [email protected] 083-788-7769. วัตถุประสงค์. เข้าใจสถาปัตยกรรม SOA เข้าใจ Web Services การอ่านข้อมูลจากหน้าเว็บ พัฒนา Web Services แบบ REST. REST Representational State Transfer. API Directory.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Government Data Integration' - uma-garza


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
government data integration

Government Data Integration

หลักสูตรเบื้องต้น

REST

[email protected]

083-788-7769

slide2
วัตถุประสงค์

เข้าใจสถาปัตยกรรม SOA

เข้าใจ Web Services

การอ่านข้อมูลจากหน้าเว็บ

พัฒนา Web Services แบบ REST

api directory
API Directory

http://www.programmableweb.com/apis/directory

http://www.webmashup.com

http://www.webapi.org/

http://www.webservicelist.com/

web document

HTML

CSS

JavaScript

Structure Layer

Presentation

Behavior

Web Document
slide7
HTML

<html>

<head><title>gdi</title></head>

<body>Hello, world</body>

</html>

slide8
CSS

<html>

<head><title>gdi</title></head>

<body>

<div style="color:red;">Hello, world</div>

</body>

</html>

javascript
JavaScript

<html>

<head><title>gdi</title></head>

<body>

<div onClick="alert(\'you click\');">Hello, world</div>

</body>

</html>

slide11

def test_nokogiri

require \'nokogiri\'

require \'open-uri\'

doc = Nokogiri::HTML(open(\'http://www.google.com/search?q=ruby\'))

t=[]

doc.css(\'a.l\').each do |link|

t << "<b>#{link.content}</b> #{link[\'href\']}"

end

render :text => t.join("<br/>")

end

slide12

http://scrubyt.org/

sudo gem install scrubyt

sudo gem install firewatir

google
Google

require \'rubygems\'

require \'scrubyt\'

google_data = Scrubyt::Extractor.define do

  fetch \'http://www.google.com/search?hl=en&q=ruby\'

  link_title "//a[@class=\'l\']", :write_text =>truedo

    link_url

end

end

p google_data.to_hash

slide14
Ebay

ebay_data = Scrubyt::Extractor.define do

fetch \'http://www.ebay.com/‘

fill_textfield \'satitle\', \'ipod‘

submit ; click_link \'Apple iPod‘

record do

item_name \'APPLE NEW IPOD MINI 6GB MP3 PLAYER SILVER‘

price \'$71.99‘

end

next_page \'Next >\', :limit => 5

end

scrubyt installation
ScRUBYt Installation

sudo gem install hpricot

sudo gem install mechanize

sudo gem install scrubyt

slide16
Lab: ตลาดหลักทรัพย์แห่งประเทศไทย

http://marketdata.set.or.th/mkt/stockquotation.do?symbol=pttep

lab twitter
Lab: Twitter

สร้างเว็บเซอร์วิสที่รับชื่อผู้ใช้ Twitter แล้วส่งข้อมูลออกในรูปแบบ XML

ชื่อ

ที่อยู่

เว็บไซท์

ประวัติ

ทดสอบกับชื่อเหล่านี้ songrit, iamnadia, algore, BarackObama

activerecord to xml
ActiveRecord#to_xml

print Book.first.to_xml

:only=>[...]

:skip_instruct=>true

:root=>\'books\'

:indent=>4

:dasherize=>false

:skip_types=>true

:include=>chapters

slide20
Hash

print ({:name=>\'song\', :lname=>\'lee\'}.to_xml)

hash from xml
Hash.from_xml

h = Hash.from_xml(File.new("abc.xml"))

slide22
Lab

x = <<-EOT

<export>

<mineral>20_000</mineral>

<electronic>300_000</electronic>

<fishery>50_000</fishery>

</export>

EOT

Hash.from_xml(x)

builder
Builder

xml.instruct!

xml.comment! "a comment"

xml.feed "xmlns" => "http://www.w3.org/2005/Atom" do

xml.title "My Atom Feed"

xml.subtitle h(@feed.subtitle), "type" => \'html\'

xml.link url_for( :only_path => false, :controller => \'feed\', :action => \'atom\' )

xml.updated @updated.iso8601

@entries.each do |entry|

xml.entry do

xml.title entry.title

xml.link "href" => url_for ( :only_path => false, :controller => \'entries\', :action => \'show\', :id => entry )

xml.id entry.urn

xml.updated entry.updated.iso8601

xml.summary h(entry.summary)

end

end

end

yahoo api
Yahoo API

http://developer.yahoo.com/search/web/V1/webSearch.html

http api search yahoo com websearchservice v1 websearch appid songrit gdi query gdi
http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=songrit_gdi&query=gdihttp://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=songrit_gdi&query=gdi
controller
Controller

class CodeController < ApplicationController

def yahootest

query = CGI.escape("SEARCH TEXT")

yahookey = "songrit_gdi"

url = "http://api.search.yahoo.com/" +

"WebSearchService/V1/webSearch?" +

"appid=#{yahookey}&query=#{query}" +

"&results=3&start=1"

result = Net::HTTP.get(URI(url))

@doc = REXML::Document.new result

end

end

slide28
View

<% @doc.root.each_element do |res| %>

<b>Title:</b> <%= res[0].text.to_s %><br>

<b>Summary:</b> <%= res[1].text.to_s %><br>

<b>Link:</b>

<a href="<%= res[2].text.to_s %>"><%= res[2].text.to_s % />

<br><br>

<% end %>

slide29
Lab

http://sites.google.com/site/songrit/Home/my-files/rexml_lab.xml

lab create new rexml document
Lab: create new REXML::Document

require "rexml/document“

file = File.new( "rexml_lab.xml" )

doc = REXML::Document.new file

accessing elements
Accessing Elements

doc.elements.each("inventory/section") { |element|

puts element.attributes["name"]

}

slide32

root = doc.root

puts root.attributes["title"]

puts root.elements["section/item[@stock=\'44\']"].attributes["upc"]

google maps
Google Maps

Obsolete

ruby script/plugin install git://github.com/joergbattermann/gmaps_on_rails.git

signup at http://www.google.com/apis/maps/signup.html

environment rb
environment.rb

Obsolete

localhost:3000

GOOGLE_APPLICATION_ID = "ABQIAAAA3HdfrnxFAPWyY-aiJUxmqRTJQa0g3IQ9GZqIMmInSLzwtGDKaBQ0KYLwBEKSM7F9gCevcsIf6WPuIQ"

slide35
View

Obsolete

<% map = GoogleMap.new

map.markers << GoogleMapMarker.new(

:map => map, :lat => 47.6597,

:lng => -122.318, :html => \'My House\') %>

<%= map.to_html %>

<div style="width: 500px; height: 500px;"> <%= map.div %> </div>

google map v3
Google Map V3

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">

</script>

slide38

<script type="text/javascript">

function initialize() {

var latLng = new google.maps.LatLng(14, 100);

var map = new google.maps.Map(document.getElementById(\'mapCanvas\'), {

zoom: 8,

center: latLng,

mapTypeId: google.maps.MapTypeId.ROADMAP

});

slide39

var marker = new google.maps.Marker({

position: latLng,

title: \'Point A\',

map: map,

draggable: true

});

}

google.maps.event.addDomListener(window, \'load\', initialize);

</script>

slide40

<style>

#mapCanvas {

width: 500px;

height: 500px;

}

</style>

<div id="mapCanvas"></div>

slide41
Lab

All districts in Nontaburi

slide42
Lab

get data from http://www.fedspending.org/apidoc.php

display top 10 contractors and amount for state of California

ad