OLD | NEW |
(Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 import json |
| 5 import os |
| 6 |
| 7 from telemetry.page import page as page_module |
| 8 from telemetry.page import shared_page_state |
| 9 from telemetry import story |
| 10 |
| 11 |
| 12 _ALEXA_TOP500_JSON = os.path.join( |
| 13 os.path.abspath(os.path.dirname(__file__)), 'alexa_top_500.json') |
| 14 _ALEXA_TOP500_JSON_BLACKLIST = os.path.join( |
| 15 os.path.abspath(os.path.dirname(__file__)), 'alexa_top_500_blacklist.json') |
| 16 |
| 17 class AlexaTop500Page(page_module.Page): |
| 18 |
| 19 def __init__(self, url, page_set): |
| 20 super(AlexaTop500Page, self).__init__( |
| 21 url=url, page_set=page_set, |
| 22 shared_page_state_class=shared_page_state.SharedDesktopPageState) |
| 23 |
| 24 def RunPageInteractions(self, action_runner): |
| 25 with action_runner.CreateGestureInteraction('ScrollAction'): |
| 26 action_runner.ScrollPage() |
| 27 |
| 28 |
| 29 class AlexaTop500PageSet(story.StorySet): |
| 30 def __init__(self): |
| 31 super(AlexaTop500PageSet, self).__init__( |
| 32 archive_data_file='data/alexa_top_500.json', |
| 33 ) |
| 34 |
| 35 excludes = set([ |
| 36 'qq.com', |
| 37 'telegraph.co.uk', |
| 38 'googleusercontent.com', |
| 39 'nba.com', |
| 40 'seznam.cz', |
| 41 'sina.com.cn', |
| 42 'youku.com', |
| 43 'zhihu.com', |
| 44 'huffingtonpost.com', |
| 45 't-online.de', |
| 46 ]) |
| 47 |
| 48 # with open(_ALEXA_TOP500_JSON_BLACKLIST) as f: |
| 49 # excludes = set(json.load(f)) |
| 50 |
| 51 sites = [] |
| 52 with open(_ALEXA_TOP500_JSON) as f: |
| 53 site_entries = json.load(f) |
| 54 for entry in site_entries: |
| 55 if entry['url'] in excludes: |
| 56 continue |
| 57 sites.append(entry['url']) |
| 58 |
| 59 MAX_PAGES = 300 |
| 60 for i, site in enumerate(sites): |
| 61 if i < MAX_PAGES: |
| 62 self.AddStory(AlexaTop500Page('http://' + site, self)) |
OLD | NEW |