Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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 xpath=>;SyntaxError:无效语法_Python_Xpath_Web Crawler - Fatal编程技术网

Python xpath=>;SyntaxError:无效语法

Python xpath=>;SyntaxError:无效语法,python,xpath,web-crawler,Python,Xpath,Web Crawler,我是python的新手。我正在尝试抓取一些文本,但它不起作用。。。 这是我的密码 def parse(self,response): hxs = Selector(response) article_list = hsx.xpath('//*[@id="weather"]') print('##################### total_length : ' + str(len(article_list))) for a in article

我是python的新手。我正在尝试抓取一些文本,但它不起作用。。。 这是我的密码

    def parse(self,response):

    hxs = Selector(response)
    article_list = hsx.xpath('//*[@id="weather"]')

    print('##################### total_length : ' + str(len(article_list)))

    for a in article_list:
        html_response = HtmlResponse(uurl="", body=a.encode('utf-8') #??
        seoul = html_response.xpath('//dl[@class="po_seoul"]//dd[@class="temp"]')[0].extract()
这是html代码

            <h1 class="blind">weather_data</h1>
            <div id="weather" class="weather" >
                <dl class="po_seoul">
                    <dt>seoul</dt>
                    <dd class="weather"><a href="#" onclick="showLandForecast('1159068000'); return false;" data-stn="108"><img src="/images/icon/NW/NB04.png" alt="cloud" /></a></dd>
                    <dt class="blind">temperature</dt>
                    <dd class="temp">21.2</dd>
                </dl>
天气数据
首尔
温度
21.2
错误消息:


seoul=html_response.xpath('//dl[@class=“po_seoul”]//dd[@class=“temp”]')[0].extract()
^
语法错误:无效语法

请帮助我…在
HtmlResponse(uurl=“”,body=a.encode('utf-8')之后,您缺少

HtmlResponse(uurl="", body=a.encode('utf-8'))
                                            ^

这一行中缺少了右括号,而不是你所拥有的。我刚刚修复了它,它工作了!谢谢你:D!