[Ruby] html 예제

왜 자꾸 까먹지..



data = Hpricot(data)


data.search('//table[@class="table_02"]')[1]


data.search('//iframe[@id="arap"]').attr('src').to_s




(str_line.search("td")[3]/"text()").to_s.strip.gsub(/\t|\n/, "")




data_list.search("//tr").each do |str_line|

# (str_line.search("td")[0]/"a"/"text()")[0].to_s

# (str_line.search("td")[0]/"text()").to_s

# str_line.search("//td[@class='center']")[0]

end




http = HTTPClient.new

post = Hash.new

post['test'] = 'value'


extheader = { 

'Referer' => @url,

"User-Agent" => 

"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E; Media Center PC 6.0; MDDS; Zune 4.7)" }


data = http.post_content(@url, post, extheader)

  or

data = http.get_content(@url)



'삽질 > Ruby' 카테고리의 다른 글

[Ruby] 빈 공간 텍스트 채우기  (0) 2014.11.28
[Ruby] Time 비교하기  (0) 2014.11.26
[Ruby] File Time  (0) 2014.11.26
[Ruby] html 예제  (0) 2014.11.26