ValueError:请求url中的缺少方案:h在python中

时间:2014-12-03 13:08:34

标签: python xpath error-handling web-scraping web-crawler

这是我的代码,我正在尝试从此网站访问评论但显示错误。

class DomainCrawlSpider(BaseSpider):
    name = "Spider"
    allowed_domains = ["www.smahavarkar.wordpress.com"]
    start_urls = "http://smahavarkar.wordpress.com/"

    def parse(self, response):
        hxs = HtmlXPathSelector(response)
        titles = hxs.select("//p")
        items = []
        for titles in titles:
            item = DItem()
            item ["address"] = titles.select("a/text()").extract()
            item ["review1"] = titles.select("p/text()").extract()
            item.append(item)
        return item

2 个答案:

答案 0 :(得分:2)

start_urls应该是一个列表,请尝试更改为:

start_urls = ["https://www.zomato.com/cs/mumbai/restaurace?q=pop%20tates"]

答案 1 :(得分:0)

start_urls更改为:

start_urls = ("http://smahavarkar.wordpress.com/",)

它对我有用。