【发布时间】:2014-07-28 20:36:59
【问题描述】:
我为 scrapy 编写了一个类,以便像这样获取页面的内容:
#!/usr/bin/python
import html2text
from scrapy.spider import BaseSpider
from scrapy.selector import HtmlXPathSelector
class StockSpider(BaseSpider):
name = "stock_spider"
allowed_domains = ["www.hamshahrionline.ir"]
start_urls = ["http://www.hamshahrionline.ir/details/261730/Health/publichealth"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
# sample = hxs.select("WhatShouldIputHere").extract()[AndHere]
converter = html2text.HTML2Text()
converter.ignore_links = True
print converter.handle(sample)
我的主要问题是我评论它的状态。
如何设置路径和提取参数?
你能指导我并给我一些例子吗?
谢谢
【问题讨论】:
-
HtmlXPathSelector已弃用。使用Selector。有关几个示例,请参阅本指南:doc.scrapy.org/en/latest/topics/selectors.html
标签: python html web-scraping scrapy extract