Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python类不接受任何参数,给定3(使用_uinit__;)_Python_Python 3.x_Web Crawler - Fatal编程技术网

Python类不接受任何参数,给定3(使用_uinit__;)

Python类不接受任何参数,给定3(使用_uinit__;),python,python-3.x,web-crawler,Python,Python 3.x,Web Crawler,我正在尝试从youtube教程等创建一个网络爬虫 我面临一个问题,我有一个不接受参数的类(其他类接受参数,结构或多或少相同) 类(crawler.py)。我使用的是\uuuu init\uuuu,其中我有3个参数 class Crawler: # class variables are shared among all crawler instances project_name = '' home_url = '' site_domain = '' #

我正在尝试从youtube教程等创建一个网络爬虫

我面临一个问题,我有一个不接受参数的类(其他类接受参数,结构或多或少相同)

类(crawler.py)。我使用的是
\uuuu init\uuuu
,其中我有3个参数

class Crawler:
    # class variables are shared among all crawler instances
    project_name = ''
    home_url = ''
    site_domain = ''
    # use set to speed up read/write process
    file_queue = ''
    queue = set()
    # use set to speed up read/write process
    file_crawled = ''
    crawled = set()

    def __init__(self, project_name, home_url, site_domain):
        Crawler.project_name = project_name
        Crawler.home_url = home_url
        Crawler.site_domain = site_domain
        Crawler.file_queue = Crawler.project_name + '/links_on_queue.txt'
        Crawler.file_crawled = Crawler.project_name + '/links_crawled.txt'
        self.starter(Crawler.site_domain)
        self.crawl_page('first_crawler', Crawler.home_url)
调用它的位置,在最后一行(main.py)

错误表示该类不接受任何参数,给出了3个参数


我正在windows上使用PyCharm社区,如果它在main.py中有帮助的话,您已经从Crawler导入了Crawler

from crawler import Crawler
您应该导入您自己实现的爬虫程序。 使用

而不是

Crawler from crawler

Crawler.project\u name=
=>
self.project\u name=
,其他的也一样,请像在实际代码中一样缩进类Crawler。代码中的缩进是否与此处相同?缩进看起来很糟糕,粘贴到此处时会发生这种情况。您确定
爬虫程序
没有被一个(或两个)星形导入覆盖/隐藏吗<代码>从通用的爬虫函数导入*听起来特别像它可以包含它。
import Crawler
Crawler from crawler