python - 如何使用“python scrapy.program.py”运行scrapy程序
问题描述
在一个教程中,我找到了这段代码
ietf.py
import scrapy
class IetfSpider(scrapy.Spider):
name = 'ietf'
allowed_domains = ['pythonscraping.com']
start_urls = ['http://pythonscraping.com/linkedin/ietf.html']
def parse(self, response):
#title = response.css("span.title::text").get()
title = response.xpath('//span[@class="title"]text()').get()
return {"title": title}
我知道如何在 powershell 中使用此命令运行此代码:
scrapy runspider ietf.py
但我想通过使用典型来运行这段代码:
python ietf.py
我需要为程序添加什么代码才能仅使用“python ietf.py”运行它?
解决方案
推荐阅读
- spring - 即使从 rsocket js 客户端发送 SETUP 帧后,@ConnectMapping 也不会被触发
- nginx - Django 频道 - 客户端有时会收到消息,而不是其他时候,直到它根本没有收到它
- python - 在中,使用 python 进行 selenium 自动化,用于 webdriver_manager.chrome 和 ChromeDriverManager
- excel - 使用 Excel 公式进行产品标记
- datadog - 我可以将标签添加到父跨度 Datadog
- r - 在R中连接具有不同向量大小的两列
- c# - 多个DataContext 一TreeView 一DataGrid 不能同时处于活动状态
- hibernate - 非空属性以主键作为连接列一对一引用空值或瞬态值
- python - 如何使用每个 JSON 文件中的名称值批量重命名 .json 文件?
- php - Laravel eloquent 中是否有允许使用 Hypertables(Postgres)的选项