Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to integrate custom scraping task in a class? #94

Closed
LeMoussel opened this issue Apr 8, 2024 · 1 comment
Closed

Is it possible to integrate custom scraping task in a class? #94

LeMoussel opened this issue Apr 8, 2024 · 1 comment

Comments

@LeMoussel
Copy link

By integrating custom scraping task _request_scrape_data into a class in this way

class RequestCrawlasaurus():
    def __init__(self, start_url=""):
        self.start_url= start_url

    @request(
            output=None,
            create_error_logs=False,
            raise_exception=True,
            parallel=3,
    )
    def _request_scrape_data(self, request: AntiDetectDriver, link):
        response = request.get(link)

    def crawl(self):
        urls = self._request_scrape_data(link=self.start_url)

I got this error: "RequestCrawlasaurus._request_scrape_data() missing 1 required positional argument: 'link'"

Is it possible to embed the custom scraping task _request scrape data into a class?
If yes, how?

@Chetan11-dev
Copy link
Contributor

Make it static, and remove self from the function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants