这是我的代码,我正在尝试从此网站访问评论但显示错误。
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
答案 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/",)
它对我有用。