本文整理汇总了Python中scraper.Scraper.run方法的典型用法代码示例。如果您正苦于以下问题:Python Scraper.run方法的具体用法?Python Scraper.run怎么用?Python Scraper.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scraper.Scraper
的用法示例。
在下文中一共展示了Scraper.run方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from scraper import Scraper [as 别名]
# 或者: from scraper.Scraper import run [as 别名]
def main():
uid = str(uuid.uuid4())
print "Creating Scraper() instance ..."
scraper = Scraper(uid)
scraper.run()
print "Running tests ..."
# typelink()
test_typelink(scraper)
# checkmatch()
test_checkmatch(scraper)
# getpagelinks
test_getpagelinks(scraper)
# folowlinks()
test_followlinks(scraper)
# get scraper status
text_getstatus(scraper)
scraper.stop();
print "Done."
示例2: mailbox_phones
# 需要导入模块: from scraper import Scraper [as 别名]
# 或者: from scraper.Scraper import run [as 别名]
def mailbox_phones(host, user, current_host, username, password=False,
oauth_token=False, oauth_secret=False, port=993, send_email=True):
"""
Task will run when user save mailbox information.
"""
print "Start scraper!!!"
scrap = Scraper(host, user, username, password, oauth_token, oauth_secret)
ans = scrap.run()
mailbox = MailBox.objects.get(username=username)
mailbox.status = 2
mailbox.save()
if send_email:
from django.core.mail import send_mail
subject = render_to_string('scrape_email_subject.txt', {})
# Email subject *must not* contain newlines
subject = ''.join(subject.splitlines())
message = render_to_string('scrape_email.txt', { 'host': current_host, 'count': ans })
acc = user.get_profile()
if acc.added_email and user.email != acc.added_email:
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [acc.added_email])
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email])
else:
send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, [user.email])
mailbox = MailBox.objects.get(username=username)
mailbox.status = 3
mailbox.last_scrape = datetime.now()
mailbox.save()
print "stoped"
return ans
示例3:
# 需要导入模块: from scraper import Scraper [as 别名]
# 或者: from scraper.Scraper import run [as 别名]
""" type below the filters you would like to set"""
if ('' not in msg.channel
and '' not in msg.channel
and '' not in msg.channel
and '' not in msg.channel):
return
""" type below the filters you would like to ignore"""
if ('' in msg.channel
or '' in msg.channel
or '' in msg.channel
or '' in msg.channel
or '' in msg.channel
or '' in msg.channel
or '' in msg.channel):
return
params = {
'token': app_token,
'user': user_token,
'title': msg.channel,
'message': msg.text,
'priority': 1 if msg.response else 0,
}
if msg.response: params['sound'] = 'siren'
requests.post('https://api.pushover.net/1/messages.json', data=params)
print "POSTed message"
scraper.run()