我在github上发现了一个有趣的刮刀。 https://github.com/apetz/email-scraper
蜘蛛从网站上截取电子邮件。你知道吗
此scraper需要以网站为参数通过命令行调用:
scrapy crawl spider -a domain="your.domain.name" -o emails-found.csv
我想编辑这个scraper,以便在我的数据库中存储电子邮件,而不是json文件。
所以我试着把“domain”参数放在/spiders/through中_蜘蛛.py在“彻头彻尾的蜘蛛”课上。你知道吗
所以在我的管道.py我写道:
import spiders.thorough_spider
为了导入包含变量的模块通透蜘蛛.domain你知道吗
但皮查姆告诉我
"No module named spiders"
是的。你知道吗
所以我试着说:
from spiders import thorough_spider
皮查姆这次告诉我
"Unresolved reference "spiders".
这是蜘蛛的代码_蜘蛛.py位于fodler“蜘蛛”中:
class ThoroughSpider(scrapy.Spider):
name = "spider"
def __init__(self, domain=None, subdomain_exclusions=[], crawl_js=False):
self.allowed_domains = [domain]
start_url = "http://" + domain
self.start_urls = [
start_url
]
这是我的密码管道.py位于“spider”文件夹上方:
from scrapy.exceptions import DropItem
import mysql.connector
import spiders.thorough_spider
from spiders import thorough_spider
您知道如何将域作为参数传递到我的是吗?
如果要从当前目录模块导入,可以使用dot
.
所以你可以试试:
它应该在工作
试试看
或者用项目名称替换“scraper”
相关问题 更多 >
编程相关推荐