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


Python downloader.Downloader類代碼示例

本文整理匯總了Python中webpage.downloader.Downloader的典型用法代碼示例。如果您正苦於以下問題:Python Downloader類的具體用法?Python Downloader怎麽用?Python Downloader使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: testDownloading_stackoverflow_2

    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)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:10,代碼來源:test_real.py

示例2: testDownloading_stackoverflow_01

    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)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:10,代碼來源:test_real.py

示例3: testDownloading_toster

    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)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:10,代碼來源:test_real.py

示例4: testDownloading_beautifulsoup

    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')
        )
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:43,代碼來源:test_real.py

示例5: testDownloading_css_03

    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))
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:39,代碼來源:test_downloader.py

示例6: testContentScriptExample1

    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)
開發者ID:Jenyay,項目名稱:outwiker,代碼行數:36,代碼來源:test_downloader.py


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