Issue
this is for example my script ,i type "scrapy crawl quotes" in the shell to execute it , so how can i launch this command in php ?
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
start_urls = [
'http://quotes.toscrape.com/page/1/',
'http://quotes.toscrape.com/page/2/',
]
def parse(self, response):
for quote in response.css('div.quote'):
yield {
'text': quote.css('span.text::text').extract_first(),
'author': quote.css('small.author::text').extract_first(),
'tags': quote.css('div.tags a.tag::text').extract(),
}
Solution
If I understand you correctly, the correct way to run php files in command line is
php file.php
If this is not what you are asking for please clarify.
EDIT
<?php
$output = shell_exec('scrapy crawl quotes');
echo "<pre>$output</pre>";
?>
This will run the terminal command in php.
Answered By - Riz-waan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.