Class: WebAnalyticsDiscovery::LiveInternet
- Inherits:
-
Object
- Object
- WebAnalyticsDiscovery::LiveInternet
show all
- Includes:
- GrabberUtils
- Defined in:
- lib/web_analytics_discovery/grabber/liveinternet.rb
Constant Summary
GrabberUtils::AVG_DAYS_IN_MONTH, GrabberUtils::CACHE_DIR, GrabberUtils::USER_AGENT
Instance Method Summary
collapse
#download, #download_file, #mangle_url
Instance Method Details
#find_id ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'lib/web_analytics_discovery/grabber/liveinternet.rb', line 16
def find_id
case @page
when /new Image\(\)\.src = "\/\/counter\.yadro\.ru\/hit;([^?"]+)\?/
$1
else
URI.parse(@url).host
end
end
|
#run(url) ⇒ Object
10
11
12
13
14
|
# File 'lib/web_analytics_discovery/grabber/liveinternet.rb', line 10
def run(url)
@url = url
@page = download(url)
run_id(find_id)
end
|
#run_id(host) ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/web_analytics_discovery/grabber/liveinternet.rb', line 26
def run_id(host)
r = {:id => host}
doc = download("http://www.liveinternet.ru/stat/#{host}/index.csv")
r[:pv_day], r[:visits_day], r[:visitors_day] = grab_psv(doc, 4)
return r unless r[:pv_day]
doc = download("http://www.liveinternet.ru/stat/#{host}/index.csv?period=week;total=yes")
r[:pv_week], r[:visits_week], r[:visitors_week] = grab_psv(doc, 2)
doc = download("http://www.liveinternet.ru/stat/#{host}/index.csv?period=month;total=yes")
r[:pv_mon], r[:visits_mon], r[:visitors_mon] = grab_psv(doc, 2)
return r
end
|