當前位置: 首頁>>代碼示例>>Python>>正文


Python scraper.Scraper方法代碼示例

本文整理匯總了Python中scraper.Scraper方法的典型用法代碼示例。如果您正苦於以下問題:Python scraper.Scraper方法的具體用法?Python scraper.Scraper怎麽用?Python scraper.Scraper使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在scraper的用法示例。


在下文中一共展示了scraper.Scraper方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import scraper [as 別名]
# 或者: from scraper import Scraper [as 別名]
def __init__(self, driver=None, driver_path=None):
        self.scraper = Scraper(driver_name=driver, driver_path=driver_path) 
開發者ID:miguelsc,項目名稱:voamos,代碼行數:4,代碼來源:flights_manager.py

示例2: scrape_league

# 需要導入模塊: import scraper [as 別名]
# 或者: from scraper import Scraper [as 別名]
def scrape_league(league_id=None):
    details_only = flask.request.args.get('detailsOnly')
    details_list = flask.request.args.get('details', '')
    start_date = flask.request.args.get('startDate')
    end_date = flask.request.args.get('endDate')
    
    url_rule = flask.request.url_rule
    if url_rule.rule.startswith('/scrape-all'):
        league_list = constants.LEAGUE_SPORT_MAP.keys()
        details_list = True
    else:
        if league_id in constants.LEAGUE_SPORT_MAP:
            league_list = [league_id]
        else:
            return '404 Not Found', 404
        
        details_list = [x.lower() for x in details_list.split(',')]
        
    for league_key in league_list:
        scraper_object = scraper.Scraper(league_key)
        
        try:
            if not details_only:
                scraper_object.fill_game_list(start_date, end_date)
            
            if details_list is True or 'odds' in details_list:
                scraper_object.fill_game_odds()
                
            if details_list is True or 'pitchers' in details_list:
                scraper_object.fill_pitchers()
        except DeadlineExceededError as e:
            # one of the sites probably temporarily down
            logging.exception(e)
    
    return 'Success' 
開發者ID:jnguyen-ca,項目名稱:gae-sports-data,代碼行數:37,代碼來源:routing.py

示例3: main

# 需要導入模塊: import scraper [as 別名]
# 或者: from scraper import Scraper [as 別名]
def main(cls):
        parser = ArgumentParser(description='Scrapes "Who Wants to be Hired?" HN Posts.')
        parser.add_argument("-s", "--source", help="The source url to scrape.")
        parser.add_argument("-t", "--technologies", nargs="*", help="The technology(ies) to filter on.")
        parser.add_argument("-l", "--location", nargs="*", help="The location(s) to filter on.")
        parser.add_argument("-rel", "--relocate", action='store_true', help="Applies a filter of 'willing to relocate' = Yes.")
        parser.add_argument("-rem", "--remote", action='store_true', help="Applies a filter of 'willing to work remotely' = Yes.")
        args = parser.parse_args()

        filters = {}
        if args.technologies is not None:
            filters[Candidate.META_TECHNOLOGIES] = args.technologies
        if args.location is not None:
            filters[Candidate.META_LOCATION] = args.location
        if args.relocate:
            filters[Candidate.META_RELOCATE] = "Yes"
        if args.remote:
            filters[Candidate.META_REMOTE] = "Yes"

        url = args.source
        url = cls.getDefaultSourceUrl() if url is None else url

        print "\nParsing Source: " + url

        html = Scraper(url).get()
        data = HackernewsParser(html, filters)
        title = data.getTitle()
        candidates = data.getCandidates()

        print "\n" + json.dumps(candidates, indent=4, sort_keys=True)
        print "\nParsed Source: " + title
        print "\nTotal Matches Found: " + str(len(candidates)) 
開發者ID:dsposito,項目名稱:hackernews-recruiter,代碼行數:34,代碼來源:cli.py

示例4: getDefaultSourceUrl

# 需要導入模塊: import scraper [as 別名]
# 或者: from scraper import Scraper [as 別名]
def getDefaultSourceUrl():
        month = datetime.now().strftime("%B %Y")
        url = "https://www.google.com/search" \
            + "?as_qdr=all&complete=0" \
            + "&q=hackernews%20who%20wants%20to%20be%20hired%20" + month

        html = Scraper(url).get()

        return GoogleParser(html).getFirstResultUrl() 
開發者ID:dsposito,項目名稱:hackernews-recruiter,代碼行數:11,代碼來源:cli.py

示例5: run_once

# 需要導入模塊: import scraper [as 別名]
# 或者: from scraper import Scraper [as 別名]
def run_once(self):
        for location, office_id in LOCATIONS.items():
            scraper = Scraper()
            self.logger.log("Checking appointment for %s" % location)
            appt = scraper.i_want_an_appointment_at(office_id)
            if appt:
                self.logger.log("Appointment retrieved from web page")
                if not self.db.appt_exists(location, appt):
                    self.logger.log("New appointment found. Added to DB.")
                    msg = "*{}*\n{}".format(location, appt)
                    self.bot.post_message(msg)
                else:
                    self.logger.log("Appointment already exists in DB.")
            else:
                self.logger.log("Invalid appointment object returned") 
開發者ID:thisisandreeeee,項目名稱:stalk-the-DMV,代碼行數:17,代碼來源:main.py


注:本文中的scraper.Scraper方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。