1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] What are the best ways to enhance the Python code of a Scrapy spider? [closed]

Discussão em 'Python' iniciado por Stack, Novembro 22, 2025.

  1. Stack

    Stack Membro Participativo

    I want to enhance the following Python code so that it can print the transcript completely, and without extra spaces.

    def parse_item(self, response):
    # Getting the article box that contains the data we want (title, plot, etc)
    article = response.xpath("//article[@class='main-article']")

    # Extract the data we want and then yield it
    yield {
    'title': article.xpath("./h1/text()").get(),
    'plot': article.xpath("./p/text()").get(),
    'transcript': article.xpath(".//div[@class='full-script']//text()").getall(),
    'url': response.url,
    }

    Continue reading...

Compartilhe esta Página