【问题标题】:How to run Scrapy/Portia on Azure Web App如何在 Azure Web App 上运行 Scrapy/Portia
【发布时间】:2015-09-14 07:34:17
【问题描述】:

我正在尝试在 Microsoft Azure Web 应用程序上运行 Scrapy 或 Portia。 我已经通过创建虚拟环境安装了 Scrapy:

D:\Python27\Scripts\virtualenv.exe D:\home\Python

然后安装Scrapy:

D:\home\Python\Scripts\pip install Scrapy

安装似乎成功了。但是执行蜘蛛会返回以下输出:

D:\home\Python\Scripts\tutorial>d:\home\python\scripts\scrapy.exe crawl example 2015-09-13 23:09:31 [scrapy] INFO: Scrapy 1.0.3 started (bot: tutorial)

2015-09-13 23:09:31 [scrapy] INFO: Optional features available: ssl, http11

2015-09-13 23:09:31 [scrapy] INFO: Overridden settings: {'NEWSPIDER_MODULE': 'tutorial.spiders', 'SPIDER_MODULES': ['tutorial.spiders'], 'BOT_NAME': 'tutorial'}

2015-09-13 23:09:34 [scrapy] INFO: Enabled extensions: CloseSpider, TelnetConsole, LogStats, CoreStats, SpiderState

Unhandled error in Deferred:

2015-09-13 23:09:35 [twisted] CRITICAL: Unhandled error in Deferred:

Traceback (most recent call last):

  File "D:\home\Python\lib\site-packages\scrapy\cmdline.py", line 150, in _run_command

    cmd.run(args, opts)

  File "D:\home\Python\lib\site-packages\scrapy\commands\crawl.py", line 57, in run

    self.crawler_process.crawl(spname, **opts.spargs)

  File "D:\home\Python\lib\site-packages\scrapy\crawler.py", line 153, in crawl

    d = crawler.crawl(*args, **kwargs)

  File "D:\home\Python\lib\site-packages\twisted\internet\defer.py", line 1274, in unwindGenerator

    return _inlineCallbacks(None, gen, Deferred())

--- <exception caught here> ---

  File "D:\home\Python\lib\site-packages\twisted\internet\defer.py", line 1128, in _inlineCallbacks

    result = g.send(result)

  File "D:\home\Python\lib\site-packages\scrapy\crawler.py", line 71, in crawl

    self.engine = self._create_engine()

  File "D:\home\Python\lib\site-packages\scrapy\crawler.py", line 83, in _create_engine

    return ExecutionEngine(self, lambda _: self.stop())

  File "D:\home\Python\lib\site-packages\scrapy\core\engine.py", line 66, in __init__

    self.downloader = downloader_cls(crawler)

  File "D:\home\Python\lib\site-packages\scrapy\core\downloader\__init__.py", line 65, in __init__

    self.handlers = DownloadHandlers(crawler)

  File "D:\home\Python\lib\site-packages\scrapy\core\downloader\handlers\__init__.py", line 23, in __init__

    cls = load_object(clspath)

  File "D:\home\Python\lib\site-packages\scrapy\utils\misc.py", line 44, in load_object

    mod = import_module(module)

  File "D:\Python27\Lib\importlib\__init__.py", line 37, in import_module

    __import__(name)

  File "D:\home\Python\lib\site-packages\scrapy\core\downloader\handlers\s3.py", line 6, in <module>

    from .http import HTTPDownloadHandler

  File "D:\home\Python\lib\site-packages\scrapy\core\downloader\handlers\http.py", line 5, in <module>

    from .http11 import HTTP11DownloadHandler as HTTPDownloadHandler

  File "D:\home\Python\lib\site-packages\scrapy\core\downloader\handlers\http11.py", line 15, in <module>

    from scrapy.xlib.tx import Agent, ProxyAgent, ResponseDone, \

  File "D:\home\Python\lib\site-packages\scrapy\xlib\tx\__init__.py", line 3, in <module>

    from twisted.web import client

  File "D:\home\Python\lib\site-packages\twisted\web\client.py", line 42, in <module>

    from twisted.internet.endpoints import TCP4ClientEndpoint, SSL4ClientEndpoint

  File "D:\home\Python\lib\site-packages\twisted\internet\endpoints.py", line 34, in <module>

    from twisted.internet.stdio import StandardIO, PipeAddress

  File "D:\home\Python\lib\site-packages\twisted\internet\stdio.py", line 30, in <module>

    from twisted.internet import _win32stdio

  File "D:\home\Python\lib\site-packages\twisted\internet\_win32stdio.py", line 7, in <module>

    import win32api

exceptions.ImportError: No module named win32api



2015-09-13 23:09:35 [twisted] CRITICAL:

文档http://doc.scrapy.org/en/latest/intro/install.html 说我必须安装pywin32。我不知道如何通过命令行下载/安装它,因为我在 web 应用程序环境中。

是否可以在 Azure Web 应用程序上运行 Scrapy 或 Portia,还是我必须在 Azure 上使用成熟的虚拟机?

谢谢!

【问题讨论】:

  • 请注意,您可以从Scrapy Cloud 运行您的蜘蛛(有免费计划和免责声明:在那里工作)。然后,您可以使用 API 或直接转储来获取数据。

标签: azure scrapy portia


【解决方案1】:

您不能在 Azure Web 应用程序“上”运行通用 Windows 应用程序。在 Azure 上作为 Web 应用程序运行的东西必须专门为此而构建。 因此,您必须在 Azure 上使用成熟的虚拟机。

Azure Webapps 似乎可以运行一些 Python 应用程序,如果它们是基于特定框架构建的: https://azure.microsoft.com/en-us/documentation/articles/web-sites-python-configure/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-17
    • 2016-09-01
    • 2023-03-20
    • 2020-01-01
    • 1970-01-01
    • 2015-03-20
    • 2017-02-24
    • 2016-10-10
    相关资源
    最近更新 更多