本文整理汇总了Python中webpage.downloader.Downloader.start方法的典型用法代码示例。如果您正苦于以下问题:Python Downloader.start方法的具体用法?Python Downloader.start怎么用?Python Downloader.start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webpage.downloader.Downloader
的用法示例。
在下文中一共展示了Downloader.start方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testDownloading_stackoverflow_2
# 需要导入模块: from webpage.downloader import Downloader [as 别名]
# 或者: from webpage.downloader.Downloader import start [as 别名]
def testDownloading_stackoverflow_2(self):
from webpage.downloader import Downloader, DownloadController
controller = DownloadController(self._tempDir, self._staticDirName)
downloader = Downloader()
url = 'https://ru.stackoverflow.com/questions/241337/Как-обработать-кириллические-символы-в-urllib-request-urlopen'
downloader.start(url, controller)
self.assertTrue(downloader.success)
示例2: testDownloading_stackoverflow_01
# 需要导入模块: from webpage.downloader import Downloader [as 别名]
# 或者: from webpage.downloader.Downloader import start [as 别名]
def testDownloading_stackoverflow_01(self):
from webpage.downloader import Downloader, DownloadController
controller = DownloadController(self._tempDir, self._staticDirName)
downloader = Downloader()
url = 'http://ru.stackoverflow.com/questions/476918/django-%D0%97%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D0%B5-%D0%B2-%D0%B7%D0%B0%D0%B2%D0%B8%D1%81%D0%B8%D0%BC%D0%BE%D1%81%D1%82%D0%B8-%D0%BE%D1%82-%D0%B7%D0%BD%D0%B0%D1%87%D0%B5%D0%BD%D0%B8%D0%B9-%D0%B2-%D0%91%D0%94'
downloader.start(url, controller)
self.assertTrue(downloader.success)
示例3: testDownloading_toster
# 需要导入模块: from webpage.downloader import Downloader [as 别名]
# 或者: from webpage.downloader.Downloader import start [as 别名]
def testDownloading_toster(self):
from webpage.downloader import Downloader, DownloadController
controller = DownloadController(self._tempDir, self._staticDirName)
downloader = Downloader()
url = 'https://toster.ru/q/273244'
downloader.start(url, controller)
self.assertTrue(downloader.success)
示例4: testDownloading_beautifulsoup
# 需要导入模块: from webpage.downloader import Downloader [as 别名]
# 或者: from webpage.downloader.Downloader import start [as 别名]
def testDownloading_beautifulsoup(self):
from webpage.downloader import Downloader, DownloadController
controller = DownloadController(self._tempDir, self._staticDirName)
downloader = Downloader()
url = 'http://www.crummy.com/software/BeautifulSoup/bs4/doc/'
downloader.start(url, controller)
self.assertTrue(downloader.success)
downloadDir = os.path.join(self._tempDir, self._staticDirName)
self.assertTrue(os.path.exists(downloadDir))
self.assertTrue(os.path.join(
self._tempDir,
self._staticDirName,
'default.css')
)
self.assertTrue(os.path.join(
self._tempDir,
self._staticDirName,
'pygments.css')
)
self.assertTrue(os.path.join(
self._tempDir,
self._staticDirName,
'jquery.js')
)
self.assertTrue(os.path.join(
self._tempDir,
self._staticDirName,
'underscore.js')
)
self.assertTrue(os.path.join(
self._tempDir,
self._staticDirName,
'doctools.js')
)
示例5: testDownloading_css_03
# 需要导入模块: from webpage.downloader import Downloader [as 别名]
# 或者: from webpage.downloader.Downloader import start [as 别名]
def testDownloading_css_03(self):
from webpage.downloader import Downloader, DownloadController
controller = DownloadController(self._tempDir, self._staticDirName)
downloader = Downloader()
examplePath = '../test/webpage/Пример 3/'
exampleHtmlPath = os.path.join(examplePath, 'пример 3.html')
downloader.start(self._path2url(exampleHtmlPath), controller)
downloadDir = os.path.join(self._tempDir, self._staticDirName)
fname1 = os.path.join(self._tempDir,
self._staticDirName,
'fname1.css')
fname2 = os.path.join(self._tempDir,
self._staticDirName,
'fname2.css')
fname3 = os.path.join(self._tempDir,
self._staticDirName,
'fname3.css')
fname4 = os.path.join(self._tempDir,
self._staticDirName,
'fname4.css')
fname5 = os.path.join(self._tempDir,
self._staticDirName,
'fname1_1.css')
self.assertTrue(os.path.exists(downloadDir))
self.assertTrue(os.path.exists(fname1))
self.assertTrue(os.path.exists(fname2))
self.assertTrue(os.path.exists(fname3))
self.assertTrue(os.path.exists(fname4))
self.assertTrue(os.path.exists(fname5))
示例6: testContentScriptExample1
# 需要导入模块: from webpage.downloader import Downloader [as 别名]
# 或者: from webpage.downloader.Downloader import start [as 别名]
def testContentScriptExample1(self):
from webpage.downloader import Downloader, DownloadController
template = '<script src="{path}"'
controller = DownloadController(self._tempDir, self._staticDirName)
downloader = Downloader()
examplePath = '../test/webpage/example1/'
exampleHtmlPath = os.path.join(examplePath, 'example1.html')
downloader.start(self._path2url(exampleHtmlPath), controller)
self.assertIn(
template.format(path=self._staticDirName + '/fname1.js'),
downloader.contentResult)
self.assertIn(
template.format(path=self._staticDirName + '/fname2.js'),
downloader.contentResult)
self.assertIn(
template.format(path=self._staticDirName + '/fname2_1.js'),
downloader.contentResult)
self.assertIn(
template.format(path=self._staticDirName + '/fname3.js'),
downloader.contentResult)
self.assertIn(
template.format(path=self._staticDirName + '/fname4.js'),
downloader.contentResult)
self.assertNotIn(
template.format(path=self._staticDirName + '/fname1_1.js'),
downloader.contentResult)