-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtester.rb
107 lines (69 loc) · 2.28 KB
/
tester.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# A file for testing out different scraping / XML traversals
require 'nokogiri'
require 'mechanize'
require 'net/http'
require 'json'
require 'open-uri'
require 'net/http'
def google(query)
agent = Mechanize.new
agent.get('http://google.com/') do |page|
search_result = page.form_with(:name => 'f') do |search|
search.q = "#{query}"
end.submit
return search_result
end
end
page = google('install itunes wine ubuntu 10.04')
journal_url = page.search('#ires').search('li')[0].search('h3').search('a')[0].attributes['href'].text().split('&')[0].split('=')[1]
p URI::decode(journal_url)
#p links.search('//a[contains(@text,"ingentaConnect")]').count
#for link in links
# p link.text()
#end
#link = page.search('//a[text()="Access Full"]')
#link = page.search('//a[contains(text(), "Access Full")]')
# .search('//a[text() = "wobidah"]')
# .search('//td[text()="${nbsp}"]
# .search('//*[contains(@id, "_divSpecialities")]')
# find the highest number in a string
#text of each a tag
#pages = %w( www.rubycentral.com
# www.awl.com
# www.pragmaticprogrammer.com
# )
#threads = []
#for page in pages
# threads << Thread.new(page) { |myPage|
# h = Net::HTTP.new(myPage, 80)
# puts "Fetching: #{myPage}"
# resp, data = h.get('/')
# puts "Got #{myPage}: #{resp.message}"
# }
#end
#p threads
#threads.each { |aThread| aThread.join }
#load './jab.rb'
#bar
#fu = Jab.new
#fu.foo
##tests = [
## id.search("[text()*='2012']").count ,
## id.search("[text()*='2011']").count ,
## id.search("[text()*='2010']").count ,
## id.search("[text()*='2009']").count ,
##]
#@tests = []
#(2010..2012).map {|x| x="[text()*='#{x}']"; @tests << page.search(x).count}
#p @tests
# file = Mechanize.new.get(entry['rss'])
# @noko = Nokogiri::XML(file.content)
# p @noko.class # => Nokogiri::XML::Document
##[1,2,3,4].map &:to_s is just short for [1,2,3,4].map { |x| x.to_s }
##p tests.any?(&:instance_of? == Nokogiri::XML::NodeSet )
##if x == true &&
#p page.search("[text()*='2012']").instance_of? Nokogiri::XML::NodeSet
#file = Mechanize.new.get(entry['rss'])
#@noko = Nokogiri::XML(file.content)
#p @noko.class # => Nokogiri::XML::Document
#name = journal.search('li.submenuli/a')[0].text().gsub(/[\r\n\t]/,'')