本文整理汇总了Python中Crawler.Crawler.start方法的典型用法代码示例。如果您正苦于以下问题:Python Crawler.start方法的具体用法?Python Crawler.start怎么用?Python Crawler.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crawler.Crawler
的用法示例。
在下文中一共展示了Crawler.start方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from Crawler import Crawler [as 别名]
# 或者: from Crawler.Crawler import start [as 别名]
def main():
t1 = task("http://www.laurentluce.com/posts/python-threads-synchronization-locks-rlocks-semaphores-conditions-events-and-queues/")
t2 = task("http://stackoverflow.com/questions/15651128/in-this-semaphore-example-is-it-necessary-to-lock-for-refill-and-buy")
t3 = task("http://bbs.byr.cn/")
event = Event()
tasks = TaskQueue(event)
pages = TaskQueue(None)
tasks.add(t1)
tasks.add(t2)
tasks.add(t3)
taskLock = BoundedSemaphore(tasks.numOfNewTasks)
pageLock = BoundedSemaphore(1)
f = open("test.txt",'w')
Connector0 = Connector(tasks,taskLock,pages,pageLock,event,'',f, 3000)
Connector1 = Connector(tasks,taskLock,pages,pageLock,event,'',f, 3001)
Connector0.start()
Connector1.start()
Crawler0 = Crawler('',3000)
Crawler1 = Crawler('',3001)
Crawler0.start()
Crawler1.start()
Connector1.join()
Connector0.join()
Crawler0.join()
Crawler1.join()
f.close()
示例2: validate_args
# 需要导入模块: from Crawler import Crawler [as 别名]
# 或者: from Crawler.Crawler import start [as 别名]
import argparse
from Crawler import Crawler
def validate_args(args):
return args
def parse_args():
parser = argparse.ArgumentParser(description="Scans a website for vulnerabilities")
parser.add_argument("base", metavar="base", type=str, help="base URL to start from")
parser.add_argument("--proxy", dest="proxy", type=str, default=False)
parser.add_argument("--proxy_port", dest="proxy_port", type=int, default=False)
parser.add_argument(
"--robots",
dest="robots",
action="store_const",
const="True",
default=False,
help="Use robots.txt (Default=False)",
)
return validate_args(parser.parse_args())
args = parse_args()
c = Crawler(args.base, args.proxy, args.proxy_port, args.robots)
c.start()
示例3: main
# 需要导入模块: from Crawler import Crawler [as 别名]
# 或者: from Crawler.Crawler import start [as 别名]
def main():
crawler = Crawler('http://www.douyutv.com/67373')
crawler.start()