'Why do I get this bracket not closed error

I am attempting to learn scrapy but I have run across this error and can't seem to find where it is coming from. The error appears on the final row under the ( after response.xpath

import scrapy
import logging

class CountriesSpider(scrapy.Spider):
    name = 'countries'
    allowed_domains = ['www.worldometers.info']
    start_urls = ['https://www.worldometers.info/world-population/population-by-country/']

    def parse(self, response):
        countries = response.xpath("//td/a")
        for country in countries:
            name = country.xpath(".//text()").get()
            link = country.xpath(".//@href").get()

            # absolute_url = f"htpps://www.worldometers.info{link}"
            # absolute_url = response.urljoin(link)
            # yield scrapy.Request(url=absolute_url) 
            yield response.follow(url=link, callback=self.parse_country)
                 
    def parse_country(self, response):
        rows = response.xpath("(//table[@class="table table-striped table-bordered table-hover table-condensed table-list"])[1]/tbody/tr")

error



Solution 1:[1]

Last line you are nesting quotes (") inside of a string declared with quotes.

Use \" to escape the quote or declare the quote with ' instead of "

Solution 2:[2]

Because you haven't used escape key for the double quotes

I have corrected below:

def parse_country(self, response):
        rows = response.xpath("(//table[@class=\"table table-striped table-bordered table-hover table-condensed table-list\"])[1]/tbody/tr")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hannes Ziegler
Solution 2 High-Octane