Example #1
0
    def discover(self, url, format=None):
        from scrape import Session
        
        s = Session(agent='Banana King')
        r = s.go(url)
        head = r.first('head', enders='/head')
        
        if not format or (format == 'json'):
            try:
                tag = head.firsttag('link', type='application/json+oembed')
                return tag['href']
            
            except Exception:
                pass

        if not format or (format == 'xml'):
            try:
                head.firsttag('link', type='application/xml+oembed')
                return tag['href']
            
            except Exception:
                pass
        
        return None
Example #2
0
    s.connect(SMTP_HOST)

    if SMTP_TTLS:
        logger.debug('Starting TTLS')
        s.starttls()

    if SMTP_USERNAME:
        logger.debug('Logging into SMTP server')
        s.login(SMTP_USERNAME, SMTP_PASSWORD)

    s.sendmail(SENDER_EMAIL, [KINDLE_EMAIL], msg.as_string())
    s.quit()

### Program

s = Session()
logger.debug('Started session')

logger.debug('Logging in')
s.go(LOGIN_URL, login_data)

logger.debug(s.url)
#if s.doc.find('onjuist'):
#    logger.error('Password and/or username incorrect')
#    exit()

logger.debug('Logged in')

latest = s.doc.firsttag('a', href=mobi_regex_compiled)

latest_url = latest['href']