简体   繁体   English

如何在heroku的rails应用程序中运行python脚本?

[英]How to run python script inside rails application in heroku?

I have a rails application hosted in heroku.我在 heroku 中托管了一个 rails 应用程序。 I also wrote a web scraper using scrapy in python.我还在python中使用scrapy编写了一个网络爬虫。 I need to run the python script from the rails application in heroku,I will explain with an example.我需要从heroku中的rails应用程序运行python脚本,我将用一个例子来解释。

Eg:The user will input the url to scrape in my rails app.Then the rails app give control to python script to scrape data which sends response as json object.Then we have to render the json result in the web app.I have to host this application in heroku.例如:用户将在我的 rails 应用程序中输入要抓取的 url。然后 rails 应用程序将控制权交给 python 脚本来抓取数据,这些数据将响应作为 json 对象发送。然后我们必须在 web 应用程序中呈现 json 结果。我必须在 heroku 中托管此应用程序。

There is a great gem called rubypython .有一个很棒的 gem 叫做rubypython It embeds a running Python interpreter in the Ruby application.它在 Ruby 应用程序中嵌入了一个正在运行的 Python 解释器。

FYI their homepage仅供参考他们的主页

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM